/* static/css/style.css */

body {
    font-family: system-ui, sans-serif;
  }
  
  .navbar-brand img {
    border-radius: 6px;
  }
  
  .text-danger {
    margin-top: 4px;
  }

/* Search bar styles */
.search-container {
  max-width: 400px;
  width: 100%;
  transition: max-width 0.3s ease;
}

.search-wrapper {
  width: 100%;
  display: flex;
}

.search-input {
  transition: all 0.3s ease;
}

.search-container.expanded {
  max-width: 600px;
}

.search-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Makes sure search results align with the expanded search field */
#searchResults {
  width: 100%;
  left: 0;
}

/* Make sure search result items don't wrap text */
.search-result-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Species Selection Modal Styles */
.species-item {
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  padding: 8px 15px;
  margin: 5px 0;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background-color: white;
}

.species-item:hover {
  border-color: #a0a0a0;
}

.species-item.selected {
  background-color: #e3f2fd;
  color: #1976d2;
  border-color: #2196f3;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.2);
  font-weight: 600;
  position: relative;
  padding-right: 30px;
}

.species-item.selected::before {
  content: "\2713";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: #2196f3;
  font-weight: bold;
  font-size: 14px;
}

/* New style for newly created topics */
.species-item.new-topic {
  animation: pulse-border 2s ease-in-out;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 123, 255, 0); }
  50% { box-shadow: 0 0 0 8px rgba(0, 123, 255, 0.3); }
}

#speciesModal .modal-content {
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  border: none;
}

#speciesFilter {
  border-radius: 20px;
  padding: 12px 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  border: 1px solid #e9ecef;
}

#speciesDoneBtn {
  border-radius: 8px;
  font-weight: 600;
  background-color: #212529;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: all 0.2s ease;
}

#speciesDoneBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.species-item {
  padding: 12px;
  margin-bottom: 10px;
  transition: all 0.3s ease;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}

#speciesMenuBtn {
  border-radius: 50%;
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* AI summary typography */
.ai-summary {
  font-size: 0.95rem;
  color: #212529;
}
.ai-summary p {
  margin-bottom: 0.5rem;
}
.ai-summary ul,
.ai-summary ol {
  margin: 0.25rem 0 0.75rem 1.25rem;
}
.ai-summary li {
  margin-bottom: 0.25rem;
}
.ai-summary h1,
.ai-summary h2,
.ai-summary h3,
.ai-summary h4,
.ai-summary h5,
.ai-summary h6 {
  font-size: 1rem;
  margin: 0.5rem 0 0.25rem;
}
.ai-summary a {
  text-decoration: none;
}
.ai-summary a:hover {
  text-decoration: underline;
}

/* Social news enhancements */
.social-filter-card {
  border-radius: 1rem;
}

.social-filter-card h5 {
  font-weight: 600;
}

.quick-range-group {
  gap: 0.5rem !important;
}

.quick-range-btn {
  border-radius: 999px;
  padding: 0.25rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: all 0.2s ease;
}

.quick-range-btn.active,
.quick-range-btn:focus-visible {
  color: #fff;
  background-color: #0d6efd;
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.quick-range-btn:hover {
  border-color: #0d6efd;
  color: #0d6efd;
}

.social-topics-select {
  min-height: 8.5rem;
}

.social-filter-card .form-label {
  font-weight: 500;
}

.source-toggle {
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid #dee2e6;
  background: #f8f9fa;
  color: #495057;
  transition: all 0.2s ease;
  line-height: 1.1;
}

.source-toggle:hover {
  background: #e9ecef;
  color: #212529;
}

.btn-check:focus-visible + .source-toggle {
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.btn-check:checked + .source-toggle {
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

.btn-check:checked + .source-toggle-google {
  background: #0d6efd;
}

.btn-check:checked + .source-toggle-reddit {
  background: #ff4500;
}

.btn-check:checked + .source-toggle-x {
  background: #1f2933;
}

.btn-check:checked + .source-toggle-facebook {
  background: #1877f2;
}

.btn-check:checked + .source-toggle-instagram {
  background: #dd2a7b;
}

.bg-dark-subtle { background-color: #e2e3e5 !important; }
.text-dark-emphasis { color: #343a40 !important; }
.bg-primary-subtle { background-color: rgba(13, 110, 253, 0.12) !important; }
.bg-danger-subtle { background-color: rgba(220, 53, 69, 0.12) !important; }
.bg-warning-subtle { background-color: rgba(255, 193, 7, 0.18) !important; }

.source-toggle-instagram {
  color: #cc2e92;
  border-color: rgba(221, 42, 123, 0.25);
}



.social-stat-grid {
  margin-top: 0.5rem;
}

.social-stat-card {
  border: none;
  border-radius: 1.25rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  background: linear-gradient(135deg, #f8f9fa 0%, #eef1f6 100%);
}

.social-stat-card .badge {
  font-weight: 600;
  letter-spacing: 0.2px;
}

.social-stat-card i {
  font-size: 1.5rem;
  opacity: 0.55;
}

.social-stat-card .stat-value {
  font-size: 2.4rem;
  font-weight: 600;
  line-height: 1.1;
  margin-bottom: 0.35rem;
  color: #0f172a;
}

.social-stat-card small {
  font-size: 0.8rem;
}

.social-stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
}

.social-stat-card.google {
  background: linear-gradient(135deg, rgba(13, 110, 253, 0.15) 0%, rgba(13, 110, 253, 0.05) 100%);
}

.social-stat-card.reddit {
  background: linear-gradient(135deg, rgba(255, 69, 0, 0.18) 0%, rgba(255, 69, 0, 0.05) 100%);
}

.social-stat-card.x {
  background: linear-gradient(135deg, rgba(31, 41, 51, 0.2) 0%, rgba(31, 41, 51, 0.08) 100%);
}

.social-stat-card.facebook {
  background: linear-gradient(135deg, rgba(24, 119, 242, 0.16) 0%, rgba(24, 119, 242, 0.05) 100%);
}

.social-stat-card.instagram {
  background: linear-gradient(135deg, rgba(245, 133, 41, 0.22), rgba(221, 42, 123, 0.18), rgba(129, 52, 175, 0.18));
}

/* Chat workspace layout */
.chat-layout {
  --chat-nav-offset: 72px;
  min-height: calc(100vh - var(--chat-nav-offset));
  height: calc(100vh - var(--chat-nav-offset));
  background: #f5f7fb;
}

.chat-shell {
  min-height: inherit;
  height: inherit;
  position: relative;
}

.chat-sidebar {
  width: 320px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: transform 0.3s ease, width 0.3s ease, padding 0.3s ease;
  background: #f8f9fb;
  height: inherit;
  max-height: inherit;
  overflow: hidden;
}

.chat-sidebar-header h5 {
  font-weight: 600;
}

.chat-sidebar-body {
  gap: 1.25rem;
  min-height: 0;
  overflow-y: auto;
  gap: 1.5rem;
}

.chat-sidebar-left {
  border-right: 1px solid rgba(15, 23, 42, 0.08);
}

.chat-sidebar-right {
  border-left: 1px solid rgba(15, 23, 42, 0.08);
}

.chat-sidebar.collapsed-lg {
  width: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
}

.chat-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 1025;
}

.chat-overlay.show {
  display: block;
}

.chat-main {
  background: #fff;
  height: inherit;
  display: flex;
  flex-direction: column;
}

.chat-toolbar {
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.chat-messages {
  background: linear-gradient(180deg, #f9fafc 0%, #ffffff 120%);
}

.chat-input {
  background: #fff;
}

.chat-message {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  align-items: flex-end;
}

.chat-message-user {
  flex-direction: row-reverse;
}

.chat-message-ai {
  align-items: flex-start;
}

.chat-message-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: min(60ch, 70%);
}

.chat-message-user .chat-message-body {
  align-items: flex-end;
  text-align: right;
}

.chat-message-ai .chat-message-body {
  align-items: flex-start;
}

.chat-message-meta-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.1rem;
}

.chat-message-user .chat-message-meta-row {
  justify-content: flex-end;
}

.chat-message-ai .chat-message-meta-row {
  justify-content: flex-start;
}

.chat-message-meta {
  font-size: 0.75rem;
  color: #6c757d;
  margin-top: 0.15rem;
}

.chat-message-actions {
  display: flex;
  flex-direction: row;
  gap: 0.45rem;
  align-items: center;
}

.chat-message-actions .btn-feedback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  transition: all 0.15s ease;
}

.chat-message-actions .btn-feedback:not(.active):hover {
  background-color: rgba(13, 110, 253, 0.08);
}

.chat-message-actions .btn-feedback i {
  font-size: 1.05rem;
}

.chat-message-ai.pending .chat-bubble {
  color: #6c757d;
  font-style: italic;
}

.chat-message-user .chat-message-meta {
  text-align: right;
  align-self: flex-end;
}

.chat-message-ai .chat-message-meta {
  align-self: flex-start;
}

.chat-bubble {
  display: inline-block;
  max-width: min(620px, 90%);
  padding: 0.9rem 1.1rem;
  border-radius: 1.1rem;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
  line-height: 1.55;
  word-break: normal;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-bubble.ai {
  background: #f2f5ff;
  color: #1f2937;
  border-top-left-radius: 0.4rem;
}

.chat-bubble.user {
  background: #0d6efd;
  color: #fff;
  border-top-right-radius: 0.4rem;
}

.workspace-docs {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.upload-dropzone {
  border: 2px dashed rgba(13, 110, 253, 0.3);
  border-radius: 1rem;
  background: rgba(13, 110, 253, 0.06);
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-dropzone.dragover {
  background: rgba(13, 110, 253, 0.14);
  border-color: rgba(13, 110, 253, 0.6);
}

.uploaded-doc-list {
  max-height: 200px;
  overflow-y: auto;
  padding-right: 0.25rem;
  flex: 1 1 auto;
}

.upload-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.reference-item strong {
  display: block;
}

.reference-item {
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed rgba(15, 23, 42, 0.12);
}

#advancedAccordion .accordion-button {
  font-weight: 600;
}

#advancedAccordion .accordion-body {
  max-height: 260px;
  overflow-y: auto;
  padding-top: 0.5rem;
}

@media (max-width: 991.98px) {
  .chat-layout .chat-sidebar {
    position: fixed;
    top: var(--chat-nav-offset);
    bottom: 0;
    z-index: 1030;
    width: 300px;
    transform: translateX(-100%);
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
    height: auto;
    max-height: none;
  }

  .chat-layout .chat-sidebar-right {
    right: 0;
    left: auto;
    transform: translateX(100%);
  }

  .chat-layout .chat-sidebar.open {
    transform: translateX(0);
  }

  .chat-layout .chat-sidebar.collapsed-lg {
    width: 300px;
    padding: 1.5rem;
  }

  .chat-main {
    min-height: calc(100vh - var(--chat-nav-offset));
  }
}

.chat-main .input-group-text {
  background: #f4f6fb;
  border-right: 0;
}

.chat-main .form-control {
  border-left: 0;
}

.chat-main .input-group:focus-within .form-control,
.chat-main .input-group:focus-within .input-group-text {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.chat-conversation-panel {
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 0.75rem;
  padding: 1rem;
  background-color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1 1 auto;
  max-height: none;
  min-height: 220px;
  overflow: hidden;
}

.chat-conversation-list .conversation-item {
  border: none;
  border-radius: 0.5rem;
  margin-bottom: 0.35rem;
  background-color: #f8f9fb;
}

.chat-conversation-list .conversation-item.active {
  background-color: #0d6efd;
  color: #ffffff;
}

.chat-conversation-list .conversation-item.active .text-muted {
  color: rgba(255, 255, 255, 0.85) !important;
}

.chat-conversation-list .conversation-item .conversation-title {
  font-weight: 600;
}

#conversationList {
  flex: 1 1 auto;
  overflow-y: auto;
  margin-top: 0;
}

.chat-sidebar-left .chat-sidebar-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.chat-sidebar-left .workspace-docs {
  flex: 0 0 auto;
  position: relative;
  z-index: 0;
}

.chat-sidebar-left .upload-dropzone {
  position: relative;
  z-index: 0;
  width: 100%;
}

.chat-sidebar-left .pinned-articles-panel {
  flex: 0 0 auto;
  position: relative;
  z-index: 0;
}

.chat-conversation-panel .btn-outline-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

#conversationEmptyState:not(.d-none) {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #6c757d;
  flex: 1 1 auto;
}
