/* Safion Widget Custom Styles */

:root {
  --safion-blue: #1da1db;
  --safion-dark-blue: #1a3c6c;
  --safion-gradient: linear-gradient(90deg, #1da1db 0%, #1a3c6c 100%);
}

.assistant-file-tab-btn {
  width: clamp(56px, 8vw, 80px) !important;
  height: clamp(56px, 8vw, 80px) !important;
  padding: clamp(6px, 1vw, 12px) !important;
}

.assistant-file-tab-btn img {
  width: 70% !important;
  height: 70% !important;
  max-width: 60px;
  object-fit: contain;
}

.assistant-card-icon {
  width: clamp(48px, 7vw, 64px);
  height: clamp(48px, 7vw, 64px);
  border-radius: 12px;
  background: linear-gradient(90deg, #1da1db 0%, #1a3c6c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(4px, 0.9vw, 8px);
  box-shadow: 0 6px 14px -6px rgba(26, 60, 108, 0.4);
  flex-shrink: 0;
}

.assistant-card-icon.file-icon {
  width: clamp(64px, 10vw, 112px);
  height: clamp(64px, 10vw, 112px);
  background: transparent;
  box-shadow: none;
  padding: clamp(8px, 1.2vw, 14px);
}

.assistant-card-icon.file-icon img {
  width: 90%;
  height: 90%;
}

.assistant-file-remove-btn {
  padding: 0.4rem 0.85rem;
  border-radius: 0.4rem;
  background: #dc2626;
  color: #fff;
  border: 1px solid #fca5a5;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.assistant-file-remove-btn:hover {
  background: #b91c1c;
}

.safion-redact-btn.cancel-mode {
  background: #dc2626 !important;
  color: #fff !important;
  border-color: #b91c1c !important;
}

.safion-redact-btn.cancel-mode:hover {
  background: #b91c1c !important;
}

.safion-redact-btn.canceling-mode {
  opacity: 0.85 !important;
  cursor: progress !important;
}

.assistant-card-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.assistant-header-info {
  width: 100%;
  min-width: 0;
}

.assistant-card-text,
.department-card-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  max-width: clamp(140px, 22vw, 260px);
  min-width: 0;
}

.assistant-card-name {
  font-size: 1.94vh;
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.assistant-card-meta {
  font-size: 1.11vh;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  .assistant-card-text,
  .department-card-text {
    max-width: 55vw;
  }

  .assistant-card-name {
    font-size: 2vh;
  }

  .assistant-card-meta {
    font-size: 1.5vh;
  }
}

/* File Status Styles */
.training-file-item[data-file-status="processed"] {
  opacity: 1;
}

.training-file-item[data-file-status="pending"] {
  opacity: 0.6;
  background-color: #f8f9fa;
}

.training-file-item[data-file-status="pending"] .file-link {
  color: #6c757d !important;
  cursor: not-allowed !important;
  text-decoration: none !important;
}

.training-file-item[data-file-status="pending"] .file-link:hover {
  color: #6c757d !important;
}

/* Status icon animation for pending files */
.training-file-item[data-file-status="pending"] .status-icon {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* Progress bar styles for pending files with progress */
.progress-container {
  min-width: 80px;
}

.progress-bar {
  background-color: #e5e7eb;
  border-radius: 9999px;
  height: 8px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  height: 100%;
  transition: width 0.3s ease-out;
  border-radius: 9999px;
}

.progress-text {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  min-width: 30px;
  text-align: right;
}

/* Animation for progress bar fill */
.progress-fill {
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Loading Modal Styles */
#save-loading-modal,
#create-loading-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Removed background override - let Tailwind bg-opacity classes handle it */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 16000;
  pointer-events: auto;
  user-select: none;
}

/* Ensure modals and overlays appear above assistant cards */
.modal-overlay,
.user-dropdown-content {
  z-index: 500000 !important;
}

/* Specific z-index for Create Assistant modal and Assistant Files panel */
#create-assistant-modal,
#assistant-file-list-panel {
  z-index: 10000 !important;
}

#save-loading-modal *,
#create-loading-modal * {
  pointer-events: none;
}

#save-loading-modal .bg-white,
#create-loading-modal .bg-white {
  pointer-events: auto;
}

#save-loading-modal .animate-spin,
#create-loading-modal .animate-spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.safion-logo {
  height: 2.78vh; /* 40px / 9px per vh */
  margin-right: 0.75rem;
}

.safion-card {
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.15);
  border: none;
  transition: box-shadow 0.25s ease, transform 0.25s ease;
  transform-origin: 0 0;
  z-index: 1;
  overflow: hidden;
}
.safion-card.active {
  box-shadow: 0 25px 55px rgba(30, 64, 175, 0.2);
}

.safion-card:not(.active):not(.fullscreen) {
  width: 29.63vw !important; /* Adjusted to fill available grid space with increased spacing */
  max-width: 29.63vw !important;
  min-width: 29.63vw !important;
  height: 20vh !important; /* Fixed height to prevent zoom-related sizing issues */
  max-height: 20vh !important;
  min-height: 20vh !important;
  overflow: hidden;
  /* font-size: 2.22vh !important; Base font size for cards - moved to assistant-card.css */
  transform: none !important; /* Prevent any transforms that might affect sizing */
  box-sizing: border-box !important; /* Ensure consistent box model */
}

.safion-card.fullscreen {
  width: 80vw !important;
  height: 75vh !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: 1200px !important;
  max-height: 843.75px !important;
  border-radius: 1.67vh; /* More rounded borders (15px / 9px per vh) */
  display: flex;
  flex-direction: column;
  /* Position to fit under top bar */
  margin-top: 8.89vh;
}

.safion-btn-primary {
  background: var(--safion-gradient);
  color: #fff;
  border-radius: 0.5rem;
  font-weight: 600;
  transition: background 0.2s;
  min-width: fit-content;
  white-space: nowrap;
}
.safion-btn-primary:hover {
  background: #1a3c6c;
}

.safion-chat-bubble {
  border-radius: 1rem;
  padding: 0.75rem 1.25rem;
  margin-bottom: 0.5rem;
  max-width: 80%;
  word-break: break-word;
}
.safion-chat-bubble.user {
  background: var(--safion-blue);
  color: #fff;
  margin-left: auto;
  text-align: right;
  align-self: flex-end;
  padding-right: 0.75rem;
  padding-left: 0.5rem;
  width: fit-content;
  max-width: 80%;
}
.safion-chat-bubble.assistant {
  background: #f1f5f9;
  color: #1a3c6c;
  margin-right: auto;
}

/* Markdown styling for assistant chat bubbles */
.safion-chat-bubble.assistant h1,
.safion-chat-bubble.assistant h2,
.safion-chat-bubble.assistant h3,
.safion-chat-bubble.assistant h4,
.safion-chat-bubble.assistant h5,
.safion-chat-bubble.assistant h6 {
  margin: 1rem 0 0.5rem 0;
  font-weight: 600;
  line-height: 1.3;
  color: #1a3c6c;
}

.safion-chat-bubble.assistant h1 {
  font-size: 3.34vh; /* 1.5rem = 24px / 9px per vh - doubled */
  border-bottom: 0.22vh solid #e2e8f0; /* 2px / 9px per vh */
  padding-bottom: 0.28vh; /* 0.25rem = 4px / 9px per vh */
}

.safion-chat-bubble.assistant h2 {
  font-size: 2.78vh; /* 1.25rem = 20px / 9px per vh - doubled */
  border-bottom: 0.11vh solid #e2e8f0; /* 1px / 9px per vh */
  padding-bottom: 0.28vh; /* 0.25rem = 4px / 9px per vh */
}

.safion-chat-bubble.assistant h3 {
  font-size: 2.5vh; /* 1.125rem = 18px / 9px per vh - doubled */
}

.safion-chat-bubble.assistant h4 {
  font-size: 2.22vh; /* 1rem = 16px / 9px per vh - doubled */
}

.safion-chat-bubble.assistant h5 {
  font-size: 1.94vh; /* 0.875rem = 14px / 9px per vh - doubled */
}

.safion-chat-bubble.assistant h6 {
  font-size: 1.66vh; /* 0.75rem = 12px / 9px per vh - doubled */
}

.safion-chat-bubble.assistant p {
  margin: 0.75rem 0;
  line-height: 1.6;
}

/* Handle line breaks within paragraphs */
.safion-chat-bubble.assistant br {
  display: block;
  content: "";
  margin: 0.25rem 0;
}

/* Better spacing for consecutive paragraphs */
.safion-chat-bubble.assistant p + p {
  margin-top: 0.5rem;
}

.safion-chat-bubble.assistant ul,
.safion-chat-bubble.assistant ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
  list-style-position: outside;
}

.safion-chat-bubble.assistant li {
  margin: 0.5rem 0;
  line-height: 1.5;
  padding-left: 0.25rem;
}

.safion-chat-bubble.assistant li p {
  margin: 0.25rem 0;
}

/* Better spacing for nested lists */
.safion-chat-bubble.assistant ul ul,
.safion-chat-bubble.assistant ol ol,
.safion-chat-bubble.assistant ul ol,
.safion-chat-bubble.assistant ol ul {
  margin: 0.25rem 0;
  padding-left: 1rem;
}

.safion-chat-bubble.assistant blockquote {
  border-left: 4px solid var(--safion-blue);
  margin: 0.75rem 0;
  padding: 0.5rem 0 0.5rem 1rem;
  background: rgba(29, 161, 219, 0.05);
  border-radius: 0 0.25rem 0.25rem 0;
  font-style: italic;
}

.safion-chat-bubble.assistant code {
  background: rgba(0, 0, 0, 0.1);
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875em;
  color: #dc2626;
}

.safion-chat-bubble.assistant pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.75rem 0;
  border: 1px solid #334155;
}

.safion-chat-bubble.assistant pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font-size: 0.875rem;
}

.safion-chat-bubble.assistant table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.75rem 0;
  font-size: 0.875rem;
}

.safion-chat-bubble.assistant th,
.safion-chat-bubble.assistant td {
  border: 1px solid #d1d5db;
  padding: 0.5rem;
  text-align: left;
}

.safion-chat-bubble.assistant th {
  background: #f9fafb;
  font-weight: 600;
}

.safion-chat-bubble.assistant tr:nth-child(even) {
  background: #f9fafb;
}

.safion-chat-bubble.assistant hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 1rem 0;
}

.safion-chat-bubble.assistant strong {
  font-weight: 600;
  color: #1a3c6c;
}

.safion-chat-bubble.assistant em {
  font-style: italic;
}

.safion-chat-bubble.assistant a {
  color: var(--safion-blue);
  text-decoration: underline;
  transition: color 0.2s;
}

.safion-chat-bubble.assistant a:hover {
  color: #1a3c6c;
}

/* Custom formatting styles for all chat bubbles */
.safion-chat-bubble strong {
  font-weight: bold;
}

.safion-chat-bubble em {
  font-style: italic;
}

.safion-chat-bubble u {
  text-decoration: underline;
}

.safion-chat-bubble div[style*="text-align: center"] {
  margin: 0.5em 0;
}

.safion-chat-bubble div[style*="text-align: left"] {
  margin: 0.5em 0;
}

.safion-chat-bubble div[style*="text-align: right"] {
  margin: 0.5em 0;
}

/* Custom formatting classes for chat bubbles */
.safion-chat-bubble .format-header1 {
  font-size: 1.5em;
  font-weight: bold;
  display: block;
  margin: 0.5em 0;
  color: #1a3c6c;
}

.safion-chat-bubble .format-center {
  text-align: center;
  margin: 0.5em 0;
}

.safion-chat-bubble .format-left {
  text-align: left;
  margin: 0.5em 0;
}

.safion-chat-bubble .format-right {
  text-align: right;
  margin: 0.5em 0;
}

.safion-chat-bubble .format-bulletin {
  margin: 0.5em 0;
  padding-left: 1em;
}

.safion-chat-bubble .format-tab {
  margin: 0.5em 0;
  padding-left: 2em;
}

.safion-chat-bubble.assistant img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 0.5rem 0;
}

.safion-chat-bubble.assistant .highlight {
  background: rgba(255, 255, 0, 0.3);
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
}

.safion-chat-bubble.assistant > *:first-child {
  margin-top: 0;
}

.safion-chat-bubble.assistant > *:last-child {
  margin-bottom: 0;
}

.safion-grid-cell {
  position: absolute;
  width: 29.63vw; /* Adjusted to fill available grid space with increased spacing */
  height: 20vh; /* Increased by 5vh to 20vh */
  border: 0.14vw dashed #e5e7eb; /* 2px / 14.4px per vw */
  border-radius: 1.67vh; /* More rounded borders (15px / 9px per vh) */
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 1.94vh; /* 0.875rem = 14px / 9px per vh - doubled */
  background: rgba(249, 250, 251, 0.5);
}

.safion-card-anim {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#global-toggle-switch {
  position: relative;
}

#global-toggle-switch .w-14 {
  width: 3.5rem;
}

#global-toggle-switch .h-8 {
  height: 2rem;
}

#global-toggle-switch .dot {
  position: absolute;
  top: 0.25rem;
  left: 0.25rem;
  width: 1.5rem;
  height: 1.5rem;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#global-toggle-switch input:checked ~ .dot {
  transform: translateX(1.5rem);
}

#global-toggle-switch .dot svg {
  width: 0.75rem;
  height: 0.75rem;
  color: #6b7280;
}

.safion-chat-input {
  width: 100%;
  min-height: 2.78vh; /* 2.5rem = 25px / 9px per vh */
  max-height: 25vh; /* Increased to allow up to 10 rows (approximately 25vh) */
  padding: 0.56vh 0.83vw; /* 0.5rem 0.75rem = 5px 11px / 9px per vh, 14.4px per vw */
  border: 0.11vh solid #d1d5db; /* 1px / 9px per vh */
  border-radius: 0.56vh; /* 0.5rem = 5px / 9px per vh */
  font-size: 1.94vh; /* 0.875rem = 14px / 9px per vh - doubled */
  line-height: 1.39vh; /* 1.25rem = 20px / 9px per vh */
  resize: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, height 0.2s ease;
  font-family: inherit;
}

.safion-chat-input:focus {
  border-color: var(--safion-blue);
  box-shadow: 0 0 0 3px rgba(29, 161, 219, 0.1);
}

.safion-card:not(.fullscreen) .safion-chat-input {
  min-height: 2.22vh; /* 2rem = 20px / 9px per vh */
  max-height: 25vh; /* Increased to allow up to 10 rows (approximately 25vh) */
  font-size: 1.66vh; /* 0.75rem = 12px / 9px per vh - doubled */
  padding: 0.42vh 0.69vw; /* 0.375rem 0.5rem = 3.375px 7.2px / 9px per vh, 14.4px per vw */
  line-height: 1.11vh; /* 1rem = 16px / 9px per vh */
}

.safion-card:not(.fullscreen) .safion-chat-input:focus {
  box-shadow: 0 0 0 2px rgba(29, 161, 219, 0.1);
}

.safion-card.fullscreen .safion-chat-input {
  min-height: 3.33vh; /* 3rem = 30px / 9px per vh */
  max-height: 25vh; /* Increased to allow up to 10 rows (approximately 25vh) */
  font-size: 2.22vh; /* 1rem = 16px / 9px per vh - doubled */
  padding: 0.83vh 1.39vw; /* 0.75rem 1rem = 6.75px 14.4px / 9px per vh, 14.4px per vw */
  line-height: 1.67vh; /* 1.5rem = 24px / 9px per vh */
}

.safion-card.fullscreen .safion-chat-input.overflow {
  max-height: 8rem;
}

.safion-chat-input-card {
  width: 100%;
  min-height: 2.22vh; /* 2rem = 20px / 9px per vh */
  max-height: 25vh; /* Increased to allow up to 10 rows (approximately 25vh) */
  padding: 0.42vh 0.69vw; /* 0.375rem 0.5rem = 3.375px 7.2px / 9px per vh, 14.4px per vw */
  border: 0.11vh solid #d1d5db; /* 1px / 9px per vh */
  border-radius: 0.56vh; /* 0.5rem = 5px / 9px per vh */
  font-size: 1.66vh; /* 0.75rem = 12px / 9px per vh - doubled */
  line-height: 1.11vh; /* 1rem = 16px / 9px per vh */
  resize: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, height 0.2s ease;
  font-family: inherit;
  background: white;
  border: 0.11vh solid #d1d5db; /* 1px / 9px per vh */
}

.safion-chat-input-card:focus {
  border-color: var(--safion-blue);
  box-shadow: 0 0 0 0.22vh rgba(29, 161, 219, 0.1); /* 2px / 9px per vh */
}

.safion-chat-input-fullscreen {
  /* Fullscreen version - expandable textarea */
  min-height: 2.78vh; /* 2.5rem = 25px / 9px per vh */
  max-height: 25vh; /* Increased to allow up to 10 rows (approximately 25vh) */
  resize: none;
  overflow: hidden;
  word-wrap: break-word;
  white-space: pre-wrap;
  line-height: 1.4;
  border: 0.11vh solid #d1d5db; /* 1px / 9px per vh */
  border-radius: 0.56vh; /* 0.5rem = 5px / 9px per vh */
  padding: 0.56vh 0.83vw; /* 0.5rem 0.75rem = 5px 12px / 9px per vh, 14.4px per vw */
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, height 0.2s ease;
  font-family: inherit;
  font-size: 1.67vh; /* 14px / 9px per vh */
  background: white;
}

.safion-chat-input-fullscreen:focus {
  border-color: var(--safion-blue);
  box-shadow: 0 0 0 2px rgba(29, 161, 219, 0.2);
}

/* When fullscreen textarea exceeds max height */
.safion-chat-input-fullscreen.overflow {
  overflow-y: auto;
}

/* Redact button styling - matches Clear History button height */
.safion-redact-btn {
  align-self: flex-start;
  margin-top: 0;
  padding: 1.11vh 1.67vw; /* Match Clear History button padding */
  font-size: 1.67vh; /* 14px / 9px per vh */
  font-weight: 600;
  border-radius: 0.56vh; /* 0.5rem = 5px / 9px per vh */
  background: var(--safion-gradient);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.safion-redact-btn:hover {
  background: #1a3c6c;
}

.safion-chat-link-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.15rem 0.25rem;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 0.45rem;
  background: var(--safion-gradient);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: background 0.2s ease, transform 0.1s ease;
}

.safion-chat-link-button:hover,
.safion-chat-link-button:focus-visible {
  background: #1a3c6c;
  transform: translateY(-1px);
}

.safion-chat-link-button:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.safion-chat-link-button:focus {
  outline: 2px solid rgba(26, 60, 108, 0.4);
  outline-offset: 2px;
}

.safion-chat-link {
  color: #1a3c6c;
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
}

.safion-chat-link:hover,
.safion-chat-link:focus-visible {
  color: #0f2a4a;
  text-decoration: underline;
}

.safion-chat-link:focus {
  outline: 2px solid rgba(26, 60, 108, 0.4);
  outline-offset: 2px;
}

/* Chat Input Container fixed to bottom */
.chat-input-container {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding-bottom: 1.11vh; /* 1rem = 9px / 9px per vh */
  background: transparent;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  height: 25vh; /* Increased to accommodate larger textarea (up to 10 rows) */
}

/* Chat Input expands upwards */
.safion-chat-input-card,
.safion-chat-input-fullscreen {
  min-height: 2.5rem;
  max-height: 25rem; /* Increased to allow up to 10 rows */
  resize: none;
  overflow-y: auto;
  display: block;
  width: 100%;
  box-sizing: border-box;
  transition: height 0.2s ease;
  /* To expand upwards, use flex-direction: column-reverse on parent */
}

.chat-form {
  width: 100%;
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-direction: row;
}

.chat-input-container {
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  justify-content: flex-end;
}

/* Chat history should use all available space */
.chat-history {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  /* Remove the margin-bottom since we're using fixed heights now */
  margin-bottom: 0 !important;
  /* Ensure it doesn't grow beyond its container */
  max-height: 100%;
  /* Prevent it from pushing the input area out of view */
  position: relative;
  /* Add extra scrollable space (responsive to viewport) */
  padding-bottom: 25vh;
}

.chat-history::-webkit-scrollbar {
  width: 0.67vh; /* 6px / 9px per vh */
}

.chat-history::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 0.33vh; /* 3px / 9px per vh */
}

.chat-history::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 0.33vh; /* 3px / 9px per vh */
}

.chat-history::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

#conversation-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 0.11vh solid #d1d5db; /* 1px / 9px per vh */
  border-radius: 0.56vh; /* 0.5rem = 5px / 9px per vh */
  box-shadow: 0 0.44vh 0.67vh -0.11vh rgba(0, 0, 0, 0.1); /* 4px 6px -1px / 9px per vh */
  z-index: 1000;
  max-height: 33.33vh; /* 300px / 9px per vh */
  overflow-y: auto;
}

#conversation-search-dropdown .flex {
  padding: 0.83vh 1.11vw; /* 0.75rem = 6.75px / 9px per vh, 16px / 14.4px per vw */
  border-bottom: 0.11vh solid #f3f4f6; /* 1px / 9px per vh */
  cursor: pointer;
}

#conversation-search-dropdown .flex:hover {
  background: #f9fafb;
}

/* Fullscreen modal specific styles */
.safion-card.fullscreen .chat-history {
  margin-bottom: 0 !important;
  /* Fullscreen chat history should scroll within its allocated space */
  height: calc(100vh - 25vh);
  overflow-y: auto;
  /* Add extra scrollable space for fullscreen */
  padding-bottom: 25vh;
  transition: height 0.3s ease-out, max-height 0.3s ease-out;
}

.safion-card.fullscreen .chat-input-container {
  background: transparent;
  backdrop-filter: none;
  transition: bottom 0.3s ease-out;
  /* Ensure it's positioned at the bottom */
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 10 !important;
}

/* Regular card chat history should also scroll properly */
.safion-card:not(.fullscreen) .chat-history {
  height: calc(100% - 15vh);
  overflow: hidden; /* Prevent scroll bars in regular cards */
  margin-bottom: 0 !important;
  /* When showing placeholder/summary text, position it at 40% from top and centered */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 2rem;
  text-align: center;
}

/* Ensure consistent sizing for card body elements */
.safion-card:not(.fullscreen) .chat-history {
  height: calc(100% - 15vh);
  overflow: hidden;
  margin-bottom: 0 !important;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 2rem;
  text-align: center;
}

/* Make textarea normal appearance */
.safion-chat-input-card,
.safion-chat-input-fullscreen {
  background: white;
  border: 1px solid #d1d5db;
  transition: all 0.3s ease;
}

.safion-chat-input-card:focus,
.safion-chat-input-fullscreen:focus {
  border-color: var(--safion-blue);
  box-shadow: 0 0 0 2px rgba(29, 161, 219, 0.2);
}

.user-dropdown {
  position: relative;
  display: inline-block;
}

.user-dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  background-color: white;
  min-width: 160px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
  border-radius: 8px;
  z-index: 500000;
  margin-top: 8px;
}

.user-dropdown-content.show {
  display: block;
}

.user-dropdown-content a {
  color: #374151;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  transition: background-color 0.2s;
}

.user-dropdown-content a:hover {
  background-color: #f3f4f6;
}


.modal-overlay.show {
  visibility: visible;
}

.modal {
  background: white;
  border-radius: 0.5rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.modal-overlay.show .modal {
  transform: scale(1);
}

.profile-modal-container {
  padding: 2rem;
  background: #ffffff;
}

.profile-modal-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 1.5rem;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1da1db, #1a3c6c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
}

.profile-name {
  font-size: 1.75rem;
  font-weight: 600;
  color: #1a3c6c;
  margin: 0;
}

.profile-subtitle {
  color: #64748b;
  margin-top: 0.25rem;
}

.profile-modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.profile-card-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.profile-info-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1rem;
}

.profile-info-card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.25rem;
}

.profile-info-card p {
  font-size: 1.1rem;
  font-weight: 600;
  color: #0f172a;
}

.profile-prompt-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.05);
}

.profile-prompt-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.profile-prompt-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #1a3c6c;
}

.profile-prompt-header p {
  margin: 0.2rem 0 0 0;
  color: #64748b;
  font-size: 0.9rem;
}

.prompt-info-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #cbd5f5;
  background: #eef2ff;
  color: #1d4ed8;
  font-weight: 600;
  cursor: pointer;
  position: relative;
}

.prompt-tooltip {
  position: absolute;
  top: 120%;
  right: 0;
  width: 260px;
  background: #1a3c6c;
  color: #fff;
  padding: 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.3;
  box-shadow: 0 15px 30px rgba(15, 23, 42, 0.2);
  display: none;
  z-index: 10;
}

.prompt-tooltip.show {
  display: block;
}

.profile-prompt-input {
  width: 100%;
  min-height: 120px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 1rem;
  font-size: 1rem;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.profile-prompt-input:focus {
  border-color: #1da1db;
  box-shadow: 0 0 0 3px rgba(29, 161, 219, 0.2);
  outline: none;
}

.profile-modal-footer {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* Reference modal styles */
.reference-modal {
  width: 90vw;
  max-width: 960px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.reference-modal .modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.reference-metadata-summary {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
}

.reference-metadata-summary .summary-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.reference-metadata-summary .summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem 1rem;
  font-size: 0.9rem;
}

.reference-metadata-summary .summary-label {
  color: #64748b;
  font-weight: 500;
  margin-right: 0.25rem;
}

.reference-metadata-summary .summary-value {
  color: #1e293b;
}

.reference-content-container {
  flex: 1;
  min-height: 320px;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #ffffff;
}

.reference-text-wrapper {
  height: 100%;
  padding: 1rem;
  overflow-y: auto;
}

.reference-text-wrapper pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #0f172a;
}

.reference-spreadsheet-wrapper {
  height: 100%;
}

.reference-modal-tabular .jspreadsheet,
.reference-modal-tabular .jspreadsheet-container {
  height: 100% !important;
}

.reference-metadata-footer {
  background: #f8fafc;
  border-radius: 0.75rem;
  border: 1px solid #e2e8f0;
  padding: 1rem 1.25rem;
}

.reference-metadata-footer .payload-preview {
  margin-top: 0.75rem;
  max-height: 120px;
  overflow: auto;
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
}

.reference-modal .modal-footer {
  margin-top: 1.5rem;
}

/* Text Highlighting Styles */
.text-highlight {
  background-color: #fff3cd;
  padding: 2px 4px;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.text-highlight:hover {
  background-color: #ffeaa7;
}

.highlight-toolbar {
  position: absolute;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  padding: 0.5rem;
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.highlight-btn {
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: transform 0.2s;
}

.highlight-btn:hover {
  transform: scale(1.1);
}

.highlight-menu {
  position: absolute;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  min-width: 120px;
}

.menu-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background-color 0.2s;
  border-radius: 0.25rem;
  margin: 0.125rem;
}

.menu-item:hover {
  background-color: #f3f4f6;
}

/* Notification Styles */
.notification {
  position: fixed;
  top: 1rem;
  right: 1rem;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.notification.show {
  transform: translateX(0);
}

/* Loading States */
.loading-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid #f3f4f6;
  border-radius: 50%;
  border-top-color: var(--safion-blue);
  animation: spin 1s ease-in-out infinite;
}

.loading-dots {
  display: inline-block;
}

.loading-dots::after {
  content: '';
  animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* Responsive Design */
@media (max-width: 768px) {
  .safion-card:not(.fullscreen) {
    width: 20rem !important;
    height: 8rem !important;
    max-width: 20rem;
    max-height: 8rem;
  }
  
  .safion-grid-cell {
    width: 20rem;
    height: 8rem;
  }
  
  #conversation-search-bar {
    width: 200px;
  }
  
  .modal {
    max-width: 95vw;
    margin: 1rem;
  }
}

@media (max-width: 480px) {
  .safion-card:not(.fullscreen) {
    width: 18rem !important;
    height: 7rem !important;
    max-width: 18rem;
    max-height: 7rem;
  }
  
  .safion-grid-cell {
    width: 18rem;
    height: 7rem;
  }
  
  #conversation-search-bar {
    width: 150px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Prevent zoom-related resizing for legacy chat content */
@media screen {
  .safion-card:not(.fullscreen) .legacy-chat-section {
    transform: scale(1) !important;
    zoom: 1 !important;
    -webkit-transform: scale(1) !important;
    -moz-transform: scale(1) !important;
    -ms-transform: scale(1) !important;
  }
  
  .safion-card:not(.fullscreen) .legacy-chat-section * {
    transform: none !important;
    zoom: 1 !important;
    -webkit-transform: none !important;
    -moz-transform: none !important;
    -ms-transform: none !important;
  }
}

/* Focus styles for accessibility */
.safion-btn-primary:focus,
.safion-chat-input:focus,
.modal-close:focus,
.user-dropdown-btn:focus,
.close-fullscreen-btn:focus {
  outline: 2px solid var(--safion-blue);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .safion-card {
    border: 2px solid #000;
  }
  
  .safion-chat-bubble {
    border: 1px solid #000;
  }
  
  .safion-btn-primary {
    border: 2px solid #000;
  }
}

/* Print styles */
@media print {
  .safion-topbar,
  .chat-input-container,
  .modal-overlay {
    display: none !important;
  }
  
  .safion-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #000;
  }
}

/* LaTeX Math Styling */
.math-inline {
  display: inline-block;
  margin: 0 0.2em;
  vertical-align: middle;
}

.math-display {
  display: block;
  text-align: center;
  margin: 1em 0;
  padding: 0.5em 0;
}

/* Ensure MathJax elements are properly styled in chat bubbles */
.safion-chat-bubble .math-inline {
  font-size: inherit;
  line-height: inherit;
}

.safion-chat-bubble .math-display {
  margin: 0.5em 0;
  padding: 0.25em 0;
}

/* MathJax container styling */
.MathJax {
  outline: none;
}

/* Ensure proper spacing around math elements */


/* ========================================
   MOBILE-FIRST CHAT UI ENHANCEMENTS
   ======================================== */

/* CSS Custom Properties for Responsive Design */
:root {
  /* Mobile-first sizing variables */
  --chat-modal-width-mobile: 95vw;
  --chat-modal-height-mobile: 85vh;
  --chat-modal-width-tablet: 90vw;
  --chat-modal-height-tablet: 80vh;
  --chat-modal-width-desktop: 80vw;
  --chat-modal-height-desktop: 75vh;
  
  /* Touch-friendly sizing */
  --touch-target-min: 44px;
  --touch-padding: 12px;
  --mobile-font-base: 16px;
  --mobile-font-small: 14px;
  --mobile-font-large: 18px;
  
  /* Safe area insets for mobile devices */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
}

/* Base mobile-first fullscreen modal styles */
#assistant-fullscreen-modal {
  /* Ensure modal covers full viewport on mobile */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 11000;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--safe-area-top) var(--safe-area-right) var(--safe-area-bottom) var(--safe-area-left);
}

#assistant-fullscreen-modal .fullscreen {
  /* Mobile-first sizing */
  width: var(--chat-modal-width-mobile);
  height: var(--chat-modal-height-mobile);
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 16px;
  margin: 0;
  
  /* Ensure proper display */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: white;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Mobile-first header adjustments */
#assistant-fullscreen-modal .fullscreen > div:first-child {
  /* Mobile-optimized header */
  height: auto;
  min-height: 60px;
  padding: 12px 16px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e5e7eb;
  background: white;
  flex-shrink: 0;
  border-radius: 16px 16px 0 0;
}

/* Fullscreen modal header layout fixes */
#assistant-fullscreen-modal .fullscreen > div:first-child {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
}

#assistant-fullscreen-modal .fullscreen > div:first-child > div:first-child {
  flex: 1 !important;
  min-width: 0 !important; /* Allow shrinking */
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}

#assistant-fullscreen-modal .fullscreen > div:first-child > div:last-child {
  flex-shrink: 0 !important; /* Prevent X button from shrinking */
  display: flex !important;
  align-items: center !important;
}

#assistant-fullscreen-modal .assistant-fullscreen-name {
  font-size: var(--mobile-font-large);
  font-weight: 600;
  color: #1a3c6c;
  margin: 0;
  flex: 1;
  text-align: left;
  line-height: 1.2;
  
  /* Ellipsis behavior for text truncation */
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 15ch !important; /* Mobile: 15 characters */
  min-width: 0; /* Allow flex item to shrink below content size */
}

/* Touch-friendly buttons */
#assistant-fullscreen-modal .clear-history-btn,
#assistant-fullscreen-modal .close-fullscreen-btn {
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  padding: var(--touch-padding);
  font-size: var(--mobile-font-small);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  
  /* Softer mobile styling */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

#assistant-fullscreen-modal .clear-history-btn {
  font-weight: 500;
}

#assistant-fullscreen-modal .clear-history-btn:hover,
#assistant-fullscreen-modal .clear-history-btn:active {
  transform: translateY(-1px);
}

#assistant-fullscreen-modal .clear-history-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

#assistant-fullscreen-modal .clear-history-btn:disabled:hover,
#assistant-fullscreen-modal .clear-history-btn:disabled:active {
  transform: none;
}

#assistant-fullscreen-modal .close-fullscreen-btn {
  font-size: 24px;
  font-weight: bold;
}

/* Fullscreen body layout */
#assistant-fullscreen-modal .fullscreen > div:last-child {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f9fafb;
  padding: 24px 32px;
  gap: 24px;
}

#assistant-fullscreen-modal .fullscreen-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100%;
}

#assistant-fullscreen-modal .fullscreen-body .chat-history {
  flex: 1;
  background: #ffffff;
  border-radius: 24px;
  padding: 24px;
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.12);
  border: 1px solid #edf2f7;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

#assistant-fullscreen-modal .fullscreen-body .chat-history::-webkit-scrollbar {
  width: 6px;
}

#assistant-fullscreen-modal .fullscreen-body .chat-history::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 999px;
}

#assistant-fullscreen-modal .fullscreen-body .chat-history::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

#assistant-fullscreen-modal .fullscreen-body .chat-history::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Composer wrapper */
#assistant-fullscreen-modal .chat-input-container {
  position: static;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  box-shadow: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#assistant-fullscreen-modal .chat-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  width: 100%;
}

#assistant-fullscreen-modal .chat-form.fullscreen-composer-card {
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  background: #ffffff;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
  border: 1px solid #edf2f7;
}

#assistant-fullscreen-modal .fullscreen-composer-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

#assistant-fullscreen-modal .fullscreen-upload-btn {
  min-width: 130px;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 600;
  background: #f3f4f6;
  color: #111827;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

#assistant-fullscreen-modal .fullscreen-upload-btn,
#assistant-fullscreen-modal .fullscreen-action-stack {
  align-self: flex-start;
}

#assistant-fullscreen-modal .fullscreen-upload-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
  background: #edeff2;
}

#assistant-fullscreen-modal .fullscreen-upload-btn:focus-visible {
  outline: 2px solid var(--safion-blue);
  outline-offset: 2px;
}

#assistant-fullscreen-modal .fullscreen-upload-gallery {
  display: none;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 2px;
  align-items: stretch;
}

#assistant-fullscreen-modal .fullscreen-upload-gallery.has-items {
  display: flex;
}

#assistant-fullscreen-modal .fullscreen-action-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#assistant-fullscreen-modal .fullscreen-action-stack button {
  width: 140px;
}

#assistant-fullscreen-modal .fullscreen-upload-thumb {
  position: relative;
  flex: 0 0 140px;
  height: 90px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.2);
  border: 1px solid #e5e7eb;
  background: #0f172a;
}

#assistant-fullscreen-modal .fullscreen-upload-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#assistant-fullscreen-modal .fullscreen-upload-thumb button {
  position: absolute;
  top: 6px;
  right: 6px;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

#assistant-fullscreen-modal .fullscreen-upload-thumb button:hover {
  background: rgba(15, 23, 42, 0.95);
}

#assistant-fullscreen-modal .fullscreen-upload-gallery::-webkit-scrollbar {
  height: 6px;
}

#assistant-fullscreen-modal .fullscreen-upload-gallery::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.6);
  border-radius: 999px;
}

@media (max-width: 1024px) {
  #assistant-fullscreen-modal .fullscreen-composer-row {
    flex-direction: column;
  }
  
  #assistant-fullscreen-modal .fullscreen-upload-btn,
  #assistant-fullscreen-modal .safion-redact-btn,
  #assistant-fullscreen-modal .fullscreen-action-stack button {
    width: 100%;
  }
  
  #assistant-fullscreen-modal .fullscreen-upload-thumb {
    flex: 0 0 120px;
    height: 80px;
  }
}

/* Mobile-optimized textarea */
#assistant-fullscreen-modal .safion-chat-input-fullscreen {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  font-size: var(--mobile-font-base);
  line-height: 1.4;
  padding: 14px 18px;
  border: 1px solid #d1d5db;
  border-radius: 24px;
  resize: none;
  overflow-y: auto;
  background: white;
  transition: all 0.2s ease;
  
  /* Prevent zoom on iOS */
  font-size: 16px;
  
  /* Softer mobile styling */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

#assistant-fullscreen-modal .safion-chat-input-fullscreen:focus {
  border-color: var(--safion-blue);
  box-shadow: 0 0 0 3px rgba(29, 161, 219, 0.1);
  outline: none;
}

/* Mobile-optimized proceed button */
#assistant-fullscreen-modal .safion-redact-btn {
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  padding: 14px 22px;
  font-size: var(--mobile-font-small);
  font-weight: 600;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  
  /* Softer mobile styling */
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

#assistant-fullscreen-modal .safion-redact-btn:hover,
#assistant-fullscreen-modal .safion-redact-btn:active {
  transform: translateY(-1px);
}

/* Mobile-optimized chat bubbles */
#assistant-fullscreen-modal .safion-chat-bubble {
  border-radius: 20px;
  padding: 14px 18px;
  margin-bottom: 12px;
  max-width: 85%;
  word-break: break-word;
  font-size: var(--mobile-font-base);
  line-height: 1.4;
  position: relative;
  
  /* Mobile-specific improvements */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  
  /* Softer shadows for mobile */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

#assistant-fullscreen-modal .safion-chat-bubble.user {
  margin-left: auto;
  margin-right: 0;
  border-bottom-right-radius: 6px; /* Softer tail-like appearance */
}

#assistant-fullscreen-modal .safion-chat-bubble.assistant {
  margin-right: auto;
  margin-left: 0;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-bottom-left-radius: 6px; /* Softer tail-like appearance */
}

/* Mobile-optimized chat bubble content */
#assistant-fullscreen-modal .safion-chat-bubble p {
  margin: 0.5rem 0;
  line-height: 1.4;
}

#assistant-fullscreen-modal .safion-chat-bubble p:first-child {
  margin-top: 0;
}

#assistant-fullscreen-modal .safion-chat-bubble p:last-child {
  margin-bottom: 0;
}

/* Mobile-optimized lists in chat bubbles */
#assistant-fullscreen-modal .safion-chat-bubble ul,
#assistant-fullscreen-modal .safion-chat-bubble ol {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

#assistant-fullscreen-modal .safion-chat-bubble li {
  margin: 0.25rem 0;
  line-height: 1.4;
}

/* Mobile-optimized code blocks */
#assistant-fullscreen-modal .safion-chat-bubble code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.9em;
  word-break: break-all;
}

#assistant-fullscreen-modal .safion-chat-bubble pre {
  background: #f8f9fa;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.5rem 0;
  font-size: 0.9em;
  line-height: 1.4;
}

#assistant-fullscreen-modal .safion-chat-bubble pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  word-break: normal;
}

/* Mobile-optimized tables */
#assistant-fullscreen-modal .safion-chat-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 0.9em;
  overflow-x: auto;
  display: block;
  white-space: nowrap;
}

#assistant-fullscreen-modal .safion-chat-bubble th,
#assistant-fullscreen-modal .safion-chat-bubble td {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  text-align: left;
}

#assistant-fullscreen-modal .safion-chat-bubble th {
  background: #f8f9fa;
  font-weight: 600;
}

/* Mobile-optimized blockquotes */
#assistant-fullscreen-modal .safion-chat-bubble blockquote {
  border-left: 3px solid var(--safion-blue);
  margin: 0.5rem 0;
  padding: 0.5rem 0 0.5rem 12px;
  background: #f8f9fa;
  border-radius: 0 8px 8px 0;
  font-style: italic;
}

/* Mobile-optimized links */
#assistant-fullscreen-modal .safion-chat-bubble a {
  color: var(--safion-blue);
  text-decoration: underline;
  word-break: break-all;
}

#assistant-fullscreen-modal .safion-chat-bubble a:active {
  color: var(--safion-dark-blue);
}

/* Mobile-optimized headers in chat bubbles */
#assistant-fullscreen-modal .safion-chat-bubble h1,
#assistant-fullscreen-modal .safion-chat-bubble h2,
#assistant-fullscreen-modal .safion-chat-bubble h3,
#assistant-fullscreen-modal .safion-chat-bubble h4,
#assistant-fullscreen-modal .safion-chat-bubble h5,
#assistant-fullscreen-modal .safion-chat-bubble h6 {
  margin: 0.75rem 0 0.5rem 0;
  font-weight: 600;
  line-height: 1.3;
}

#assistant-fullscreen-modal .safion-chat-bubble h1 {
  font-size: 1.25rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.25rem;
}

#assistant-fullscreen-modal .safion-chat-bubble h2 {
  font-size: 1.125rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.25rem;
}

#assistant-fullscreen-modal .safion-chat-bubble h3 {
  font-size: 1rem;
}

#assistant-fullscreen-modal .safion-chat-bubble h4,
#assistant-fullscreen-modal .safion-chat-bubble h5,
#assistant-fullscreen-modal .safion-chat-bubble h6 {
  font-size: 0.9rem;
}

/* Mobile-optimized custom formatting classes */
#assistant-fullscreen-modal .safion-chat-bubble .format-header1 {
  font-size: 1.25rem;
  font-weight: 600;
  display: block;
  margin: 0.75rem 0 0.5rem 0;
  color: #1a3c6c;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.25rem;
}

#assistant-fullscreen-modal .safion-chat-bubble .format-center {
  text-align: center;
  margin: 0.5rem 0;
}

#assistant-fullscreen-modal .safion-chat-bubble .format-left {
  text-align: left;
  margin: 0.5rem 0;
}

#assistant-fullscreen-modal .safion-chat-bubble .format-right {
  text-align: right;
  margin: 0.5rem 0;
}

#assistant-fullscreen-modal .safion-chat-bubble .format-bulletin {
  margin: 0.5rem 0;
  padding-left: 1rem;
}

/* Mobile-optimized math elements */
#assistant-fullscreen-modal .safion-chat-bubble .math-display {
  margin: 0.75rem 0;
  text-align: center;
  overflow-x: auto;
}

#assistant-fullscreen-modal .safion-chat-bubble .math-inline {
  display: inline;
  margin: 0 2px;
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 1024px) {
  #assistant-fullscreen-modal .fullscreen {
    width: var(--chat-modal-width-tablet);
    height: var(--chat-modal-height-tablet);
    border-radius: 16px;
    margin: 0;
  }
  
  #assistant-fullscreen-modal .fullscreen > div:first-child {
    padding: 16px 20px;
    min-height: 70px;
  }
  
  #assistant-fullscreen-modal .assistant-fullscreen-name {
    font-size: 20px;
  }
  
  #assistant-fullscreen-modal .fullscreen > div:last-child {
    padding: 20px;
  }
  
  #assistant-fullscreen-modal .chat-input-container {
    padding: 20px;
  }
}

/* Desktop adjustments */
@media (min-width: 1025px) {
  #assistant-fullscreen-modal .fullscreen {
    width: var(--chat-modal-width-desktop);
    height: var(--chat-modal-height-desktop);
    max-width: 1200px;
    max-height: 843.75px;
    border-radius: 16px;
    margin: 0;
  }
  
  #assistant-fullscreen-modal .fullscreen > div:first-child {
    padding: 20px 24px;
    min-height: 80px;
  }
  
  #assistant-fullscreen-modal .assistant-fullscreen-name {
    font-size: 24px;
    max-width: 50ch !important; /* Desktop: 50 characters */
  }
  
  #assistant-fullscreen-modal .fullscreen > div:last-child {
    padding: 24px;
  }
  
  #assistant-fullscreen-modal .chat-input-container {
    padding: 24px;
  }
  
  #assistant-fullscreen-modal .safion-chat-input-fullscreen {
    font-size: 16px;
    padding: 16px 20px;
  }
  
  #assistant-fullscreen-modal .safion-chat-bubble {
    font-size: 16px;
    padding: 16px 20px;
  }
}

/* Extra small mobile devices (portrait phones) */
@media (max-width: 480px) {
  #assistant-fullscreen-modal .fullscreen {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    /* Add subtle rounded corners even on full-screen mobile */
    border-radius: 12px;
    margin: 8px;
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
  }
  
  #assistant-fullscreen-modal .fullscreen > div:first-child {
    border-radius: 12px 12px 0 0;
  }
  
  #assistant-fullscreen-modal .chat-input-container {
    border-radius: 0 0 12px 12px;
  }
  
  #assistant-fullscreen-modal .fullscreen > div:first-child {
    padding: 12px 16px;
    min-height: 56px;
  }
  
  #assistant-fullscreen-modal .assistant-fullscreen-name {
    font-size: var(--mobile-font-large);
  }
  
  #assistant-fullscreen-modal .clear-history-btn,
  #assistant-fullscreen-modal .close-fullscreen-btn {
    min-width: 40px;
    min-height: 40px;
    padding: 8px;
    font-size: 14px;
  }
  
  #assistant-fullscreen-modal .fullscreen > div:last-child {
    padding: 12px;
  }
  
  #assistant-fullscreen-modal .chat-input-container {
    padding: 12px;
  }
  
  #assistant-fullscreen-modal .safion-chat-input-fullscreen {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 12px 16px;
  }
  
  #assistant-fullscreen-modal .safion-redact-btn {
    padding: 12px 16px;
    font-size: 14px;
  }
  
  #assistant-fullscreen-modal .safion-chat-bubble {
    font-size: 15px;
    padding: 12px 16px;
    max-width: 90%;
  }
}

/* Landscape mobile devices */
@media (max-width: 896px) and (orientation: landscape) {
  #assistant-fullscreen-modal .fullscreen {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
  
  #assistant-fullscreen-modal .fullscreen > div:first-child {
    min-height: 50px;
    padding: 8px 16px;
  }
  
  #assistant-fullscreen-modal .assistant-fullscreen-name {
    font-size: var(--mobile-font-base);
  }
  
  #assistant-fullscreen-modal .fullscreen > div:last-child {
    padding: 12px;
  }
  
  #assistant-fullscreen-modal .chat-input-container {
    padding: 12px;
  }
  
  #assistant-fullscreen-modal .safion-chat-input-fullscreen {
    min-height: 40px;
    max-height: 80px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  #assistant-fullscreen-modal .safion-chat-bubble {
    border-width: 0.5px;
  }
  
  #assistant-fullscreen-modal .safion-chat-input-fullscreen {
    border-width: 0.5px;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  #assistant-fullscreen-modal * {
    transition: none !important;
    animation: none !important;
  }
}

/* Dark mode support disabled: keep consistent styling regardless of system theme */

/* Focus management for keyboard navigation */
#assistant-fullscreen-modal .safion-chat-input-fullscreen:focus,
#assistant-fullscreen-modal .safion-redact-btn:focus,
#assistant-fullscreen-modal .clear-history-btn:focus,
#assistant-fullscreen-modal .close-fullscreen-btn:focus {
  outline: 2px solid var(--safion-blue);
  outline-offset: 2px;
}

/* Ensure proper touch targets on all interactive elements */
#assistant-fullscreen-modal button,
#assistant-fullscreen-modal input,
#assistant-fullscreen-modal textarea {
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
}

/* Prevent text selection on non-text elements */
#assistant-fullscreen-modal .close-fullscreen-btn,
#assistant-fullscreen-modal .clear-history-btn,
#assistant-fullscreen-modal .safion-redact-btn {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* ========================================
   ADDITIONAL MOBILE ENHANCEMENTS
   ======================================== */

/* Mobile keyboard handling */
@media (max-width: 896px) {
  /* Adjust modal when virtual keyboard appears */
  #assistant-fullscreen-modal .fullscreen {
    transition: height 0.3s ease, width 0.3s ease;
  }
  
  /* Optimize textarea for mobile keyboards */
  #assistant-fullscreen-modal .safion-chat-input-fullscreen {
    /* Prevent zoom on focus for iOS */
    font-size: 16px !important;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }
}

/* Touch gesture improvements */
#assistant-fullscreen-modal .fullscreen-body .chat-history {
  /* Enable momentum scrolling on iOS */
  -webkit-overflow-scrolling: touch;
  
  /* Improve touch scrolling performance */
  will-change: scroll-position;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* Mobile-specific button states */
#assistant-fullscreen-modal .clear-history-btn:active,
#assistant-fullscreen-modal .close-fullscreen-btn:active,
#assistant-fullscreen-modal .safion-redact-btn:active {
  transform: scale(0.95);
  transition: transform 0.1s ease;
}

/* Mobile-optimized focus states */
#assistant-fullscreen-modal .safion-chat-input-fullscreen:focus {
  /* Prevent zoom on iOS */
  font-size: 16px !important;
  
  /* Enhanced focus ring for mobile */
  box-shadow: 0 0 0 3px rgba(29, 161, 219, 0.2);
  border-color: var(--safion-blue);
}

/* Mobile-optimized placeholder text */
#assistant-fullscreen-modal .safion-chat-input-fullscreen::placeholder {
  color: #9ca3af;
  font-size: var(--mobile-font-base);
  opacity: 1;
}

/* Mobile-optimized scrollbar for webkit browsers */
#assistant-fullscreen-modal .fullscreen-body .chat-history::-webkit-scrollbar {
  width: 6px;
}

#assistant-fullscreen-modal .fullscreen-body .chat-history::-webkit-scrollbar-track {
  background: transparent;
}

#assistant-fullscreen-modal .fullscreen-body .chat-history::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

#assistant-fullscreen-modal .fullscreen-body .chat-history::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Mobile-optimized loading states */
#assistant-fullscreen-modal .safion-chat-bubble.assistant:contains("Processing") {
  opacity: 0.8;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.8;
  }
  50% {
    opacity: 1;
  }
}

/* Mobile-optimized error states */
#assistant-fullscreen-modal .safion-chat-bubble.error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 12px;
}

/* Mobile-optimized success states */
#assistant-fullscreen-modal .safion-chat-bubble.success {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
}

/* Mobile-optimized typing indicator */
#assistant-fullscreen-modal .typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  margin-right: auto;
  margin-left: 0;
  max-width: 85%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#assistant-fullscreen-modal .typing-indicator .dot {
  width: 8px;
  height: 8px;
  background: #9ca3af;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

#assistant-fullscreen-modal .typing-indicator .dot:nth-child(2) {
  animation-delay: 0.2s;
}

#assistant-fullscreen-modal .typing-indicator .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Mobile-optimized message timestamps */
#assistant-fullscreen-modal .message-timestamp {
  font-size: 0.75rem;
  color: #9ca3af;
  text-align: center;
  margin: 0.5rem 0;
  padding: 0 1rem;
}

/* Mobile-optimized empty state */
#assistant-fullscreen-modal .chat-history:empty::before {
  content: "Start a conversation by typing a message below";
  display: block;
  text-align: center;
  color: #9ca3af;
  font-size: var(--mobile-font-base);
  padding: 2rem 1rem;
  font-style: italic;
}

/* Mobile-optimized accessibility */
@media (prefers-reduced-motion: reduce) {
  #assistant-fullscreen-modal * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode for mobile */
@media (prefers-contrast: high) {
  #assistant-fullscreen-modal .safion-chat-bubble {
    border: 2px solid currentColor;
  }
  
  #assistant-fullscreen-modal .safion-chat-input-fullscreen {
    border: 2px solid currentColor;
  }
  
  #assistant-fullscreen-modal .clear-history-btn,
  #assistant-fullscreen-modal .safion-redact-btn {
    border: 2px solid currentColor;
  }
}

/* Mobile-optimized print styles */
@media print {
  #assistant-fullscreen-modal {
    display: none !important;
  }
}

/* =====================================================
   Fullscreen Prototype Layout Overrides (ensure priority)
   ===================================================== */
#assistant-fullscreen-modal .fullscreen-body {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
  height: 100% !important;
  padding: 0 !important;
  background: #ffffff !important;
}

#assistant-fullscreen-modal .fullscreen-body .chat-history {
  flex: 1 !important;
  background: #ffffff !important;
  border-radius: 0 !important;
  padding: 32px !important;
  overflow-y: auto !important;
  box-shadow: none !important;
  border: none !important;
}

#assistant-fullscreen-modal .chat-input-container {
  position: static !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  flex-shrink: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
}

#assistant-fullscreen-modal .chat-form.fullscreen-composer-card {
  background: #ffffff !important;
  border-radius: 0 !important;
  padding: 24px 32px !important;
  box-shadow: none !important;
  border-top: 1px solid #e2e8f0 !important;
}

#assistant-fullscreen-modal .fullscreen-composer-row {
  display: flex !important;
  gap: 12px !important;
  align-items: flex-start !important;
}

#assistant-fullscreen-modal .fullscreen-upload-btn,
#assistant-fullscreen-modal .fullscreen-action-stack {
  align-self: flex-start !important;
}

/* Mobile-optimized landscape orientation */
@media (max-width: 896px) and (orientation: landscape) {
  #assistant-fullscreen-modal .fullscreen > div:first-child {
    min-height: 44px;
    padding: 8px 16px;
  }
  
  #assistant-fullscreen-modal .assistant-fullscreen-name {
    font-size: 16px;
  }
  
  #assistant-fullscreen-modal .clear-history-btn,
  #assistant-fullscreen-modal .close-fullscreen-btn {
    min-width: 36px;
    min-height: 36px;
    padding: 6px;
    font-size: 12px;
  }
  
  #assistant-fullscreen-modal .safion-chat-input-fullscreen {
    min-height: 36px;
    max-height: 60px;
    font-size: 14px;
  }
  
  #assistant-fullscreen-modal .safion-redact-btn {
    min-width: 36px;
    min-height: 36px;
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* Mobile-optimized portrait orientation */
@media (max-width: 896px) and (orientation: portrait) {
  #assistant-fullscreen-modal .fullscreen {
    height: 100vh;
    height: calc(100vh - var(--safe-area-top) - var(--safe-area-bottom));
  }
  
  #assistant-fullscreen-modal .fullscreen > div:first-child {
    min-height: 60px;
    padding: 12px 16px;
  }
  
  #assistant-fullscreen-modal .assistant-fullscreen-name {
    font-size: 18px;
  }
}
.safion-chat-bubble .MathJax_Display {
  margin: 0.5em 0 !important;
}

.safion-chat-bubble .MathJax_Display .MathJax {
  margin: 0 !important;
}

/* SharePoint Modal Styles */
.sharepoint-config-form input {
  transition: border-color 0.2s ease-in-out;
}

.sharepoint-config-form input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.sharepoint-config-form label {
  font-weight: 500;
  color: #374151;
}

/* Mobile responsive SharePoint modal */
@media (max-width: 768px) {
  .sharepoint-config-form input {
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  .sharepoint-config-form .space-y-4 > div {
    margin-bottom: 1rem;
  }
}




/* SharePoint Selected Sources Table Responsiveness */
#sharepoint-modal #selTable {
  font-size: 12px;
  table-layout: fixed; /* Force fixed layout */
  width: 100%;
}
#sharepoint-modal .selectedTableContainer { /* New class for table container */
  max-height: 50vh !important; /* Optimized height for mobile */
  overflow-y: auto !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
}
#sharepoint-modal #selTable th,
#sharepoint-modal #selTable td {
  padding: 12px 8px !important;
  font-size: 14px;
  vertical-align: middle !important;
}
#sharepoint-modal #selTable td > div { /* Flexbox for alignment */
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
}
#sharepoint-modal #selTable td span:first-child { /* Emoji alignment */
  font-size: 14px !important;
  line-height: 1 !important;
}
#sharepoint-modal #selTable button { /* Button sizing */
  padding: 6px 12px !important;
  font-size: 12px !important;
  border-radius: 6px !important;
}
/* Hide columns on tablet */
@media (max-width: 991px) {
  #sharepoint-modal #selTable th:nth-child(3), /* Size column */
  #sharepoint-modal #selTable td:nth-child(3) {
    display: none !important;
  }
}
/* Hide more columns on mobile and adjust widths */
@media (max-width: 768px) {
  #sharepoint-modal #selTable th:nth-child(3), /* Size column */
  #sharepoint-modal #selTable td:nth-child(3) {
    display: none !important;
  }
  #sharepoint-modal #selTable th:nth-child(1), #sharepoint-modal #selTable td:nth-child(1) {
    width: 30% !important;
  }
  #sharepoint-modal #selTable th:nth-child(2), #sharepoint-modal #selTable td:nth-child(2) {
    width: 50% !important;
  }
  #sharepoint-modal #selTable th:nth-child(4), #sharepoint-modal #selTable td:nth-child(4) {
    width: 20% !important;
  }
}

/* Custom Selected Sources Classes for SharePoint */
#sharepoint-modal .selected-sources-row {
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}
#sharepoint-modal .selected-sources-card {
  width: 100% !important;
  margin: 0 0 1rem 0 !important;
  border-radius: 0.5rem !important;
}

/* Table Header Centering for SharePoint */
#sharepoint-modal #selTable th {
  text-align: center !important;
}
#sharepoint-modal .table th,
#sharepoint-modal #selTable thead th {
  text-align: center !important;
}

/* Remove Button Centering for SharePoint */
#sharepoint-modal #selTable td:nth-child(4) {
  text-align: center !important;
}
#sharepoint-modal #selTable td:nth-child(4) > div {
  justify-content: center !important;
}

/* Percentage-based column widths for SharePoint */
#sharepoint-modal #selTable th:nth-child(1), #sharepoint-modal #selTable td:nth-child(1) { width: 20%; }
#sharepoint-modal #selTable th:nth-child(2), #sharepoint-modal #selTable td:nth-child(2) { width: 60%; }
#sharepoint-modal #selTable th:nth-child(3), #sharepoint-modal #selTable td:nth-child(3) { width: 10%; }
#sharepoint-modal #selTable th:nth-child(4), #sharepoint-modal #selTable td:nth-child(4) { width: 20%; }

/* Mobile-specific percentage adjustments for SharePoint */
@media (max-width: 991px) { /* Tablet */
  #sharepoint-modal #selTable th:nth-child(1), #sharepoint-modal #selTable td:nth-child(1) { width: 25% !important; }
  #sharepoint-modal #selTable th:nth-child(2), #sharepoint-modal #selTable td:nth-child(2) { width: 65% !important; }
  #sharepoint-modal #selTable th:nth-child(4), #sharepoint-modal #selTable td:nth-child(4) { width: 20% !important; }
}
@media (max-width: 768px) { /* Mobile */
  /* Optimize column widths to prevent horizontal scrolling */
  #sharepoint-modal #selTable th:nth-child(1), #sharepoint-modal #selTable td:nth-child(1) { width: 25% !important; }
  #sharepoint-modal #selTable th:nth-child(2), #sharepoint-modal #selTable td:nth-child(2) { width: 55% !important; }
  #sharepoint-modal #selTable th:nth-child(4), #sharepoint-modal #selTable td:nth-child(4) { width: 20% !important; }
  
  /* Ensure table fits within container without horizontal scroll */
  #sharepoint-modal .selectedTableContainer {
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }
  
  /* Optimize table cell content to prevent overflow */
  #sharepoint-modal #selTable td:nth-child(2) {
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    max-width: 0 !important; /* Force text wrapping */
  }
  
  /* Ensure buttons fit within their cells */
  #sharepoint-modal #selTable button {
    padding: 2px 4px !important;
    font-size: 9px !important;
    white-space: nowrap !important;
    min-width: auto !important;
  }
  
  /* Optimize emoji and badge sizing */
  #sharepoint-modal #selTable td span:first-child {
    font-size: 12px !important;
    line-height: 1 !important;
  }
  
  /* Reduce padding to maximize content space */
  #sharepoint-modal #selTable th,
  #sharepoint-modal #selTable td {
    padding: 4px 2px !important;
    font-size: 10px !important;
  }
}
