/* Smart Notes Styles */

/* Smart Notes Form */
.smart-notes-form {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1002;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  padding: 1rem;
  min-width: 300px;
  max-width: 500px;
  opacity: 0;
  visibility: hidden;
}

/* When smart notes form is active, show and adjust bottom position */
.smart-notes-form.show {
  display: block;
  bottom: calc(55px + 13px);
  opacity: 1;
  visibility: visible;
}

.smart-notes-form.show {
  opacity: 1;
  visibility: visible;
}

.smart-notes-form__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.smart-notes-form__header h6 {
  margin: 0;
  color: var(--bs-primary);
}

.selected-text-preview {
  background: var(--bs-gray-100);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.25rem;
  padding: 0.5rem;
  font-size: 0.875rem;
  color: var(--bs-gray-700);
  max-height: 100px;
  overflow-y: auto;
  font-style: italic;
}

/* Ensure form inputs work properly */
.smart-notes-form input,
.smart-notes-form textarea,
.smart-notes-form select {
  pointer-events: auto !important;
  user-select: auto !important;
  -webkit-user-select: auto !important;
  -moz-user-select: auto !important;
  -ms-user-select: auto !important;
}

/* Ensure form inputs are always interactive */
.smart-notes-form input:focus,
.smart-notes-form textarea:focus,
.smart-notes-form select:focus {
  border-color: var(--bs-primary) !important;
}

/* Prevent any interference with form inputs */
.smart-notes-form input,
.smart-notes-form textarea,
.smart-notes-form select,
.smart-notes-form button {
  position: relative !important;
  z-index: 1003 !important;
}

/* Ensure edit modal inputs work properly */
#editNoteModal input,
#editNoteModal textarea,
#editNoteModal select {
  pointer-events: auto !important;
  user-select: auto !important;
  -webkit-user-select: auto !important;
  -moz-user-select: auto !important;
  -ms-user-select: auto !important;
}

/* Ensure edit modal inputs are always interactive */
#editNoteModal input:focus,
#editNoteModal textarea:focus,
#editNoteModal select:focus {
  border-color: var(--bs-primary) !important;
}

/* Prevent any interference with edit modal inputs */
#editNoteModal input,
#editNoteModal textarea,
#editNoteModal select,
#editNoteModal button {
  position: relative !important;
  z-index: 1005 !important;
}

/* Highlighted Text Spans for Smart Notes */
.smart-note-highlighted-text {
  position: relative;
  background-color: var(--bs-primary-bg-subtle);
  border-radius: 0.125rem;
  padding: 0.125rem 0.25rem;
  margin: 0 0.125rem;
  display: inline;
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.smart-note-highlighted-text:hover {
  background-color: var(--bs-primary-hover);
}

/* Ensure highlighted text spans don't break layout */
.smart-note-highlighted-text {
  word-break: keep-all;
  white-space: normal;
  line-height: inherit;
  font-size: inherit;
  font-family: inherit;
  color: inherit;
}

/* Note Items in User Content Panel */
.smart-notes-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

.smart-note-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 1rem;
  font-size: 0.75rem;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  width: fit-content;
  max-width: 100%;
}

.smart-note-item:hover {
  background: var(--bs-primary-bg-subtle);
}

.smart-note-item--active {
  background: var(--bs-primary-bg-subtle);
  border-color: var(--bs-primary);
}

.smart-note-item-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
  white-space: nowrap;
  /* Ensure text doesn't expand the container (matching favorites behavior) */
  max-width: 100%;
  /* Ensure text is always visible - with stronger rules (matching favorites) */
  color: inherit !important;
  visibility: visible !important;
  opacity: 1 !important;
  /* Force text rendering */
  font-size: inherit !important;
  line-height: inherit !important;
  font-family: inherit !important;
  font-weight: inherit !important;
  /* Ensure proper text display */
  text-decoration: none !important;
  text-transform: none !important;
  text-align: left !important;
  /* Prevent any interference */
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  /* Allow hover effects to work */
  transition: max-width 0.2s ease, all 0.2s ease;
}

/* Hover effect: shorten text to show delete button (matching favorites behavior) */
.smart-note-item:hover .smart-note-item-title {
  max-width: calc(100% - 2rem) !important; /* Reserve space for delete button */
  text-overflow: ellipsis !important;
  /* Ensure smooth transition */
  transition: max-width 0.2s ease !important;
  /* Ensure text remains visible during hover */
  color: inherit !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Prevent horizontal overflow in smart notes container */
.smart-notes-container {
  overflow-x: hidden;
  min-width: 0;
}

/* Ensure text is always visible in all states (matching favorites) */
.smart-note-item .smart-note-item-title {
  color: inherit !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Force text visibility after layout changes (matching favorites) */
.smart-note-item .smart-note-item-title,
.smart-note-item-title {
  /* Force text to be visible */
  color: inherit !important;
  visibility: visible !important;
  opacity: 1 !important;
  /* Ensure proper text rendering */
  display: flex !important;
  align-items: center !important;
  /* Prevent any CSS interference */
  text-shadow: none !important;
  filter: none !important;
  transform: none !important;
  /* Force repaint */
  will-change: auto !important;
}

/* Additional rules to ensure text visibility in all contexts (matching favorites) */
.smart-note-item .smart-note-item-title,
.smart-note-item-title,
.smart-notes-container .smart-note-item-title,
.smart-note-item .smart-note-item-title {
  /* Ensure text is always visible regardless of parent context */
  color: inherit !important;
  visibility: visible !important;
  opacity: 1 !important;
  /* Force proper text rendering */
  display: flex !important;
  align-items: center !important;
  /* Prevent any interference */
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
  filter: none !important;
  transform: none !important;
  /* Ensure proper font rendering */
  font-size: inherit !important;
  line-height: inherit !important;
  font-family: inherit !important;
  font-weight: inherit !important;
  /* Force repaint */
  will-change: auto !important;
  /* Ensure text is not clipped - but allow hover effects */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap !important;
}

.smart-note-item-counter {
  font-size: 0.625rem;
  padding: 0.125rem 0.25rem;
  min-width: 1rem;
  text-align: center;
}

.smart-note-item-tags {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.smart-note-tag {
  font-size: 0.625rem;
  padding: 0.125rem 0.25rem;
  background: var(--bs-gray-200);
  border-radius: 0.25rem;
  color: var(--bs-gray-700);
  cursor: pointer;
  transition: all 0.2s ease;
}

.smart-note-tag:hover {
  background: var(--bs-gray-300);
}

.smart-note-tag.active {
  background: var(--bs-primary);
  color: white;
}

.smart-note-item-delete {
  display: none;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--bs-secondary);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0;
}

.smart-note-item:hover .smart-note-item-delete {
  opacity: 1;
  display: flex;
}

.smart-note-item-delete:hover {
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger);
}

/* Smart Note Tooltip Styles (matching filter tooltip structure) */
.smart-note-tooltip-container {
  min-width: 250px;
  max-width: 250px;
  background: var(--bs-white);
  overflow: hidden;
  margin-right: -8px;
}

/* Smart note tooltip header (matching filter tooltip header) */
.smart-note-tooltip-header {
  padding: 8px 0px;
  border-bottom: 1px solid var(--bs-border-color);
}

.smart-note-tooltip-header h6 {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.2;
  word-break: break-word;
}

/* Edit note title icon (matching filter edit icon) */
.edit-note-title-icon {
  cursor: pointer;
  color: var(--bs-primary);
  pointer-events: auto !important;
  z-index: 1004 !important;
  position: relative;
}

.edit-note-title-icon:hover {
  color: var(--bs-primary-hover);
}

.edit-note-title-icon * {
  pointer-events: auto !important;
}

/* Smart note tooltip body (matching filter tooltip body) */
.smart-note-tooltip-body {
  padding: 0;
  padding-top: 8px;
  max-height: 250px;
  overflow: hidden;
}

/* Smart note tooltip content */
.smart-note-tooltip-content {
  padding: 0;
}

/* Smart note tooltip selected text section */
.smart-note-tooltip-selected-text {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--bs-gray-200);
}

.smart-note-tooltip-selected-text-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bs-gray-600);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.smart-note-tooltip-selected-text-content {
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--bs-gray-700);
  display: block;
  word-break: break-word;
  white-space: normal;
  font-style: italic;
  background: var(--bs-gray-100);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  max-height: 80px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Scrollbar styling for selected text content */
.smart-note-tooltip-selected-text-content::-webkit-scrollbar,
.smart-note-tooltip-text::-webkit-scrollbar {
  width: 6px;
}

.smart-note-tooltip-selected-text-content::-webkit-scrollbar-track,
.smart-note-tooltip-text:hover::-webkit-scrollbar-track {
  background: var(--bs-gray-200);
  border-radius: 3px;
}

.smart-note-tooltip-selected-text-content::-webkit-scrollbar-thumb,
.smart-note-tooltip-text:hover::-webkit-scrollbar-thumb {
  background: var(--bs-gray-400);
  border-radius: 3px;
}

.smart-note-tooltip-selected-text-content::-webkit-scrollbar-thumb:hover,
.smart-note-tooltip-text:hover::-webkit-scrollbar-thumb:hover {
  background: var(--bs-gray-500);
}

/* Smart note tooltip text */
.smart-note-tooltip-text {
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--bs-body-color);
  display: block;
  word-break: break-word;
  white-space: normal;
  margin-bottom: 8px;
  max-height: 80px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Smart note tooltip tags */
.smart-note-tooltip-tags {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-top: 8px;
}

.smart-note-tooltip-tag {
  font-size: 0.625rem;
  padding: 0.125rem 0.25rem;
  background: var(--bs-gray-200);
  border-radius: 0.25rem;
  color: var(--bs-gray-700);
}

/* Legacy tooltip styles (kept for compatibility) */
.note-preview-tooltip {
  position: absolute;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  padding: 0.75rem;
  max-width: 300px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
}

.note-preview-tooltip.show {
  opacity: 1;
  visibility: visible;
}

.note-preview-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--bs-primary);
}

.note-preview-text {
  font-size: 0.875rem;
  color: var(--bs-gray-700);
  margin-bottom: 0.5rem;
}

.note-preview-tags {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.note-preview-tag {
  font-size: 0.625rem;
  padding: 0.125rem 0.25rem;
  background: var(--bs-gray-200);
  border-radius: 0.25rem;
  color: var(--bs-gray-700);
}

/* Tag Filter Section */
.smart-notes-tags-filter {
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: var(--bs-gray-100);
  border-radius: 0.25rem;
}

.smart-notes-tags-filter h6 {
  font-size: 0.75rem;
  margin-bottom: 0.5rem;
  color: var(--bs-gray-600);
}

.smart-notes-tags-list {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.smart-notes-tag-filter {
  font-size: 0.625rem;
  padding: 0.125rem 0.25rem;
  background: var(--bs-gray-200);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.25rem;
  color: var(--bs-gray-700);
  cursor: pointer;
  transition: all 0.2s ease;
}

.smart-notes-tag-filter:hover {
  background: var(--bs-gray-300);
}

.smart-notes-tag-filter.active {
  background: var(--bs-primary);
  color: white;
  border-color: var(--bs-primary);
}

/* Modal Preview Styles */
.selected-note-preview .selected-text-preview {
  background: var(--bs-gray-100);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.25rem;
  padding: 0.5rem;
  font-size: 0.875rem;
  color: var(--bs-gray-700);
  max-height: 80px;
  overflow-y: auto;
  font-style: italic;
}

.note-text-preview {
  background: var(--bs-primary-bg-subtle);
  border: 1px solid var(--bs-primary);
  border-radius: 0.25rem;
  padding: 0.5rem;
  font-size: 0.875rem;
  color: var(--bs-gray-700);
  max-height: 100px;
  overflow-y: auto;
}

/* Note Icons in Regulation */
.note-icon {
  display: inline-block;
  margin-right: 0.25rem;
  color: var(--bs-primary);
  cursor: pointer;
  font-size: 0.875rem;
  vertical-align: baseline;
  transition: color 0.2s ease;
  position: relative;
  z-index: 10;
}

.note-icon:hover {
  color: var(--bs-primary-hover);
}

.note-icon i {
  pointer-events: none;
}

/* Ensure note icons don't interfere with text selection */
.note-icon {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .smart-notes-form {
    position: fixed;
    bottom: 70px;
    left: 1rem;
    right: 1rem;
    transform: none;
    min-width: auto;
    max-width: none;
    /* Default transition for appearing: fast bottom, slow opacity */
    transition: opacity 0.4s ease-in-out, visibility 0.4s ease-in-out, bottom 0.1s ease-in-out;
  }

  .smart-notes-form.show {
    display: block;
    bottom: 70px;
    opacity: 1;
    visibility: visible;
    /* Transition for disappearing: fast opacity, slow bottom */
    transition: opacity 0.1s ease-in-out, visibility 0.1s ease-in-out, bottom 0.4s ease-in-out;
  }

  .note-icon {
    font-size: 0.75rem;
    margin-right: 0.125rem;
  }
}
