/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * Application-wide styles only. Agent-specific styles (competitive_intelligence,
 * consumer_intelligence) are loaded separately by their respective layouts.
 *

 */

/* Custom styles for Quill Rich Text Editor in Notebook Drawer */
.notebook-editor-container {
  display: flex;
  flex-direction: column;
  min-height: 0; /* Critical for flex overflow */
}

.notebook-editor-container .ql-toolbar {
  flex-shrink: 0; /* Toolbar stays fixed size */
}

.notebook-editor-container .ql-container {
  font-family: inherit;
  font-size: 16px !important;
  border: none;
  flex: 1;
  min-height: 0; /* Critical for flex overflow */
  overflow: hidden;
}

.notebook-editor-container .ql-editor {
  padding: 1rem;
  line-height: 1.6;
  height: 100%;
  overflow-y: auto;
}

.notebook-editor-container .ql-editor.ql-blank::before {
  color: #9CA3AF;
  font-style: normal;
}

.notebook-editor-container .ql-toolbar {
  border: none;
  border-bottom: 1px solid #E5E7EB;
  padding: 0.5rem;
  background-color: #FAFAFA;
}

.notebook-editor-container .ql-toolbar .ql-stroke {
  stroke: #6B7280;
}

.notebook-editor-container .ql-toolbar .ql-fill {
  fill: #6B7280;
}

.notebook-editor-container .ql-toolbar button:hover .ql-stroke,
.notebook-editor-container .ql-toolbar button.ql-active .ql-stroke {
  stroke: #7C3AED;
}

.notebook-editor-container .ql-toolbar button:hover .ql-fill,
.notebook-editor-container .ql-toolbar button.ql-active .ql-fill {
  fill: #7C3AED;
}

.notebook-editor-container .ql-toolbar .ql-picker-label {
  color: #6B7280;
}

.notebook-editor-container .ql-toolbar .ql-picker-label:hover,
.notebook-editor-container .ql-toolbar .ql-picker-label.ql-active {
  color: #7C3AED;
}

/* Content styling within Quill editor */
.notebook-editor-container .ql-editor h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: #111827;
}

.notebook-editor-container .ql-editor h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: #111827;
}

.notebook-editor-container .ql-editor h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: #111827;
}

.notebook-editor-container .ql-editor p {
  margin-bottom: 0.75rem;
}

.notebook-editor-container .ql-editor ul,
.notebook-editor-container .ql-editor ol {
  margin-bottom: 0.75rem;
  padding-left: 1.5rem;
}

.notebook-editor-container .ql-editor li {
  margin-bottom: 0.25rem;
}

.notebook-editor-container .ql-editor blockquote {
  border-left: 4px solid #8B5CF6;
  margin: 1rem 0;
  color: #4B5563;
  background-color: #F3F0FF;
  padding: 0.875rem 1rem;
  border-radius: 0 0.5rem 0.5rem 0;
  font-style: italic;
}

.notebook-editor-container .ql-editor a {
  color: #7C3AED;
  text-decoration: underline;
}

.notebook-editor-container .ql-editor a:hover {
  color: #5B21B6;
}

/* Markdown Table Styles */
.markdown-table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  overflow-x: auto;
  display: block;
}

.markdown-table th,
.markdown-table td {
  padding: 0.5rem;
  border: 1px solid #D7DBEC;
  text-align: left;
}

.markdown-table th {
  background-color: #F5F6FA;
  font-weight: 600;
}

.markdown-table tr:nth-child(even) {
  background-color: #F9FAFB;
}

.prose-chat table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin: 1rem 0;
}

.prose-chat th,
.prose-chat td {
  padding: 0.5rem;
  border: 1px solid #D7DBEC;
  text-align: left;
  word-wrap: break-word;
}

.prose-chat th {
  background-color: #F5F6FA;
  font-weight: 600;
}

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

/* Code block styles for chat messages */
.prose-chat pre {
  background-color: #F5F6FA;
  border-radius: 0.5rem;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}

.prose-chat pre code {
  color: #374151;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.prose-chat code:not(pre code) {
  background-color: #F5F6FA;
  color: #374151;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Thinking card styles for Claude-style reasoning UI */
/* No additional styles needed - card uses Tailwind classes */

/* ═══════════════════════════════════════════════════════════════════════════
   Chat Toggle Controls - Quiet utility style
   Secondary controls that recede until needed
   ═══════════════════════════════════════════════════════════════════════════ */

.chat-toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  padding: 0.25rem 0;
  transition: opacity 0.15s ease;
}

.chat-toggle-control:hover {
  opacity: 1;
}

/* The toggle switch - compact and understated */
.chat-toggle {
  position: relative;
  width: 1.75rem;
  height: 1rem;
  border-radius: 9999px;
  background: #e4e4e7;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
  margin-top: -1px; /* Optical alignment with text */
}

.chat-toggle:focus {
  outline: none;
}

.chat-toggle.active {
  background: #8b5cf6;
}

/* The knob - simple and clean */
.chat-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
}

.chat-toggle.active .chat-toggle-knob {
  transform: translateX(0.75rem);
}

/* Label text - quiet and secondary */
.chat-toggle-label {
  font-size: 0.75rem;
  font-weight: 400;
  color: #a1a1aa;
  letter-spacing: 0;
  transition: color 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.chat-toggle-control:hover .chat-toggle-label {
  color: #71717a;
}

/* When toggle is active, subtle emphasis via color only */
.chat-toggle.active + .chat-toggle-label {
  color: #52525b;
}

/* Send button - refined style with inactive/active states */
.chat-send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: #e5e7eb;
  color: #9ca3af;
  border: none;
  border-radius: 0.5rem;
  cursor: default;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: none;
}

.chat-send-button.active {
  background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
  color: white;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(139, 92, 246, 0.3);
}

.chat-send-button.active:hover {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  box-shadow: 0 4px 8px rgba(139, 92, 246, 0.4);
  transform: translateY(-1px);
}

.chat-send-button.active:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(139, 92, 246, 0.3);
}

/* Stop button state (during streaming) */
.chat-send-button.streaming {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  box-shadow: 0 2px 4px rgba(107, 114, 128, 0.3);
}

.chat-send-button.streaming:hover {
  background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
  box-shadow: 0 4px 8px rgba(107, 114, 128, 0.4);
}

/* ═══════════════════════════════════════════════════════════════════════════
   File Upload - Claude-style file cards
   ═══════════════════════════════════════════════════════════════════════════ */

/* Preview container - horizontal flex above textarea */
.file-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.25rem 0;
  margin-bottom: 0.5rem;
  max-height: 280px;
  overflow-y: auto;
}

.file-preview-container.hidden {
  display: none;
}

/* File card - Claude-style design */
.file-card {
  position: relative;
  width: 120px;
  height: 120px;
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.file-card:hover {
  border-color: #d1d5db;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Image preview */
.file-card-image {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.file-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* PDF preview */
.file-card-pdf {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  padding: 0.5rem;
}

.file-card-pdf-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.file-card-pdf canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Document (non-image/PDF) preview */
.file-card-document {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.5rem;
  height: 100%;
}

.file-card-name {
  font-size: 0.6875rem;
  font-weight: 500;
  color: #374151;
  word-break: break-word;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.file-card-badge {
  display: inline-flex;
  align-self: flex-start;
  margin-top: auto;
  padding: 0.25rem 0.5rem;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  background: #e5e7eb;
  border-radius: 0.25rem;
}

/* Remove button - appears on hover */
.file-card-remove {
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.file-card:hover .file-card-remove {
  opacity: 1;
}

.file-card-remove:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Upload spinner overlay */
.file-card-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.file-card.uploading .file-card-spinner {
  opacity: 1;
}

.file-card.uploading .file-card-remove {
  display: none;
}

/* Error state */
.file-card.error {
  border-color: #fca5a5;
  background: #fef2f2;
}

/* Large PDF warning badge */
.file-card-warning {
  position: absolute;
  bottom: 0.375rem;
  left: 0.375rem;
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  font-size: 0.625rem;
  font-weight: 500;
  color: #92400e;
  background: #fef3c7;
  border-radius: 0.25rem;
}

/* Drop zone overlay */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(139, 92, 246, 0.1);
  backdrop-filter: blur(2px);
}

.drop-overlay.hidden {
  display: none;
}

.drop-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 3rem;
  background: white;
  border: 2px dashed #8b5cf6;
  border-radius: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.drop-overlay-icon {
  width: 3rem;
  height: 3rem;
  color: #8b5cf6;
}

.drop-overlay-text {
  font-size: 1.125rem;
  font-weight: 500;
  color: #374151;
}

/* Attachment button - minimal style */
.file-attach-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  color: #6b7280;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease;
}

.file-attach-button:hover {
  color: #374151;
}

.file-attach-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Error messages */
.file-upload-errors {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
}

.file-upload-error {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 0.5rem;
}

/* File cards in sent messages (display mode) */
.message-files {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.message-file-card {
  width: 120px;
  height: 120px;
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.message-file-card:hover {
  border-color: #d1d5db;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.message-file-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-file-card-document {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.5rem;
  height: 100%;
}

.message-file-card-name {
  font-size: 0.6875rem;
  font-weight: 500;
  color: #374151;
  word-break: break-word;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.message-file-card-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: 0.125rem 0.375rem;
  font-size: 0.5625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  background: #e5e7eb;
  border-radius: 0.25rem;
}

/* User message container with overflow handling */
.user-message-container {
  position: relative;
}

/* Fade gradient overlay when content is truncated */
.user-message-container.has-overflow::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(to bottom, transparent 0%, #f3f4f6 60%);
  pointer-events: none;
  border-radius: 0 0 1rem 1rem;
}

/* Bottom edge indicator element - hidden by default, shown when overflow */
.user-message-container .overflow-indicator {
  display: none;
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 12px;
  cursor: pointer;
  z-index: 10;
}

/* The visible pill inside the indicator hover area */
.user-message-container .overflow-indicator::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 3px;
  background: #d1d5db;
  border-radius: 2px;
  transition: background-color 0.15s ease;
}

.user-message-container .overflow-indicator:hover::after {
  background: #9ca3af;
}

/* Show indicator when there's overflow */
.user-message-container.has-overflow .overflow-indicator {
  display: block;
}

/* Smooth scrollbar styling for user message content */
.user-message-container [data-overflow-fade-target="content"] {
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}

.user-message-container [data-overflow-fade-target="content"]::-webkit-scrollbar {
  width: 6px;
}

.user-message-container [data-overflow-fade-target="content"]::-webkit-scrollbar-track {
  background: transparent;
}

.user-message-container [data-overflow-fade-target="content"]::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
  border-radius: 3px;
}

.user-message-container [data-overflow-fade-target="content"]::-webkit-scrollbar-thumb:hover {
  background-color: #9ca3af;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Notebook Drawer Animation
   Premium entry animation with scale and transform
   ═══════════════════════════════════════════════════════════════════════════ */

.notebook-drawer {
  transform: translateX(100%) scale(0.98);
  transform-origin: right center;
  transition: transform 300ms ease-out;
}

.notebook-drawer.drawer-visible {
  transform: translateX(0) scale(1);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Context Pill - Floating Chat Context Menu
   Minimal trigger that expands to show thread info and actions
   ═══════════════════════════════════════════════════════════════════════════ */

.context-pill-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  color: #6b7280;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.context-pill-trigger:hover {
  background: #f9fafb;
  border-color: #d1d5db;
  color: #374151;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.context-pill-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 280px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  animation: contextPillFadeIn 0.15s ease;
}

@keyframes contextPillFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.context-pill-header {
  padding: 0.625rem 0.875rem;
}

.context-pill-label {
  font-size: 0.625rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.125rem;
}

.context-pill-title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #374151;
  margin: 0;
  line-height: 1.3;
}

.context-pill-grounded {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #f3f4f6;
}

.context-pill-grounded-label {
  font-size: 0.625rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.125rem;
}

.context-pill-link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #7c3aed;
  display: block;
  transition: color 0.15s ease;
  line-height: 1.3;
}

.context-pill-link:hover {
  color: #6d28d9;
}

.context-pill-divider {
  height: 1px;
  background: #f3f4f6;
}

.context-pill-actions {
  padding: 0.25rem;
}

.context-pill-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.625rem;
  font-size: 0.8125rem;
  color: #6b7280;
  background: none;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background-color 0.1s ease, color 0.1s ease;
}

.context-pill-action:hover {
  background: #f3f4f6;
  color: #374151;
}

.context-pill-action--danger {
  color: #e55a5a;
}

.context-pill-action--danger:hover {
  background: #fef2f2;
  color: #dc2626;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Context Window Indicator - Token usage display with expandable panel
   Shows context window utilization as a ring + percentage
   ═══════════════════════════════════════════════════════════════════════════ */

.context-indicator {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.context-indicator-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.context-indicator-trigger:hover {
  background: rgba(0, 0, 0, 0.05);
}

.context-indicator-ring {
  width: 20px;
  height: 20px;
  transform: rotate(-90deg);
}

.context-indicator-ring-bg {
  fill: none;
  stroke: #e5e7eb;
  stroke-width: 2;
}

.context-indicator-ring-fill {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke-dasharray 0.5s ease;
}

.context-indicator-percentage {
  font-size: 0.625rem;
  font-weight: 500;
  color: #6b7280;
  min-width: 2rem;
  text-align: right;
}

.context-indicator-panel {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 0.75rem;
  z-index: 50;
  animation: contextIndicatorFadeIn 0.15s ease;
}

@keyframes contextIndicatorFadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.context-indicator-panel-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
}

.context-indicator-bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.375rem;
}

.context-indicator-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease, background-color 0.3s ease;
}

.context-indicator-bar-fill.status-ok {
  background-color: #22c55e;
}

.context-indicator-bar-fill.status-warning {
  background-color: #eab308;
}

.context-indicator-bar-fill.status-critical {
  background-color: #ef4444;
}

.context-indicator-stats {
  font-size: 0.6875rem;
  color: #6b7280;
}

.context-indicator-warning {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: #fef3c7;
  border-radius: 0.375rem;
  font-size: 0.6875rem;
  color: #92400e;
}

.context-indicator-action {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.5rem;
  padding: 0.375rem 0.625rem;
  background: #8b5cf6;
  color: white;
  font-size: 0.6875rem;
  font-weight: 500;
  border-radius: 0.375rem;
  text-decoration: none;
  transition: background 0.15s ease;
}

.context-indicator-action:hover {
  background: #7c3aed;
}

/* Sidebar Chat Menu */
.sidebar-chat-item {
  display: flex;
  align-items: center;
  position: relative;
}

.sidebar-chat-item > a {
  flex: 1;
  min-width: 0;
}

.sidebar-chat-menu-btn {
  position: absolute;
  right: -0.5rem;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  color: #9ca3af;
  background: #1e2433;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.sidebar-chat-item:hover .sidebar-chat-menu-btn,
.sidebar-chat-menu-btn:focus {
  opacity: 1;
}

.sidebar-chat-menu-btn:hover {
  background: #2d3548;
  color: #fff;
}

.sidebar-chat-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.25rem;
  min-width: 10rem;
  background: #374151;
  border: 1px solid #4b5563;
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  z-index: 50;
  padding: 0.25rem;
  animation: sidebarDropdownFadeIn 0.1s ease;
}

@keyframes sidebarDropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sidebar-chat-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.625rem;
  font-size: 0.8125rem;
  color: #d1d5db;
  background: none;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background-color 0.1s ease, color 0.1s ease;
  text-align: left;
}

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

.sidebar-chat-dropdown-item--danger {
  color: #f87171;
}

.sidebar-chat-dropdown-item--danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.sidebar-chat-dropdown-divider {
  height: 1px;
  background: #4b5563;
  margin: 0.25rem 0;
}

/* Modal (Dark Theme) - Reusable component */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 50;
  display: none;
}

.modal-backdrop:not(.hidden) {
  display: flex;
}

.modal-panel {
  background: #374151;
  border-radius: 1rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 28rem;
  margin: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #fff;
  margin: 0 0 1rem 0;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  color: #fff;
  background: #1f2937;
  border: 2px solid #4b5563;
  border-radius: 0.5rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.modal-input:focus {
  border-color: #60a5fa;
}

.modal-input::placeholder {
  color: #9ca3af;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.modal-btn {
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.modal-btn-secondary {
  color: #d1d5db;
  background: transparent;
  border: 1px solid #4b5563;
}

.modal-btn-secondary:hover {
  background: #4b5563;
  color: #fff;
}

.modal-btn-primary {
  color: #1f2937;
  background: #fff;
  border: none;
}

.modal-btn-primary:hover {
  background: #e5e7eb;
}

/* Utility: Hide scrollbar while keeping scroll functionality */
.scrollbar-hide {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;  /* Chrome, Safari, Opera */
}

/* Highlight pulse animation for click-to-scroll feedback */
@keyframes highlight-pulse {
  0%, 100% { background-color: rgb(254 243 199); } /* amber-100 */
  50% { background-color: rgb(252 211 77); } /* amber-300 */
}

.highlight-pulse {
  animation: highlight-pulse 0.5s ease-in-out 2;
}

/* Thin scrollbar that appears on hover - for reader/sidebar views
   Note: CSS transitions on scrollbar pseudo-elements are not supported in browsers,
   so the scrollbar appears/disappears instantly rather than fading. */
.scrollbar-thin-on-hover {
  /* Firefox - use thin always to avoid layout shift, with transparent thumb until hover */
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.scrollbar-thin-on-hover:hover {
  scrollbar-color: rgb(209 213 219) transparent; /* gray-300 thumb, transparent track */
}

/* Webkit browsers (Chrome, Safari, Edge) */
.scrollbar-thin-on-hover::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.scrollbar-thin-on-hover::-webkit-scrollbar-track {
  background: transparent;
}

.scrollbar-thin-on-hover::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
}

.scrollbar-thin-on-hover:hover::-webkit-scrollbar-thumb {
  background: rgb(209 213 219); /* gray-300 */
}

.scrollbar-thin-on-hover::-webkit-scrollbar-thumb:hover {
  background: rgb(156 163 175); /* gray-400 */
}

