/*
 * App-specific styles for the diary chat application
 */

/* Trix editor customizations */
trix-editor {
  min-height: 80px;
  max-height: 200px;
  overflow-y: auto;
  border-radius: 0.5rem;
  border-color: #e5e7eb;
  padding: 0.5rem;
  font-size: 1rem;
  line-height: 1.5;
}

trix-editor:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Trix toolbar styling - only for non-chat editors */
trix-toolbar:not(.trix-chat trix-toolbar) {
  padding: 0.25rem 0;
  border-bottom: 1px solid #e5e7eb;
  background-color: #f9fafb;
  display: flex;
  justify-content: flex-start;
  overflow-x: auto;
}

trix-toolbar:not(.trix-chat trix-toolbar) .trix-button-group {
  margin-right: 0.25rem;
  border: 1px solid #e5e7eb !important;
  border-radius: 0.25rem;
  background: none !important;
}

/* Smaller buttons for non-chat editors - with high specificity */
html body trix-toolbar:not(.trix-chat trix-toolbar) .trix-button,
html body trix-toolbar:not(.trix-chat trix-toolbar) .trix-button-group button.trix-button {
  width: 1.75rem !important;
  height: 1.75rem !important;
  background-color: transparent;
  border: none;
  padding: 0 !important;
  margin: 0 !important;
  min-width: 1.75rem !important;
  max-width: 1.75rem !important;
  min-height: 1.75rem !important;
  max-height: 1.75rem !important;
}

/* Mobile improvements for non-chat trix editors */
@media (max-width: 640px) {
  /* Hide complex formatting buttons on mobile for regular editors */
  trix-toolbar:not(.trix-chat trix-toolbar) .trix-button-group--file-tools,
  trix-toolbar:not(.trix-chat trix-toolbar) .trix-button--icon-heading-1,
  trix-toolbar:not(.trix-chat trix-toolbar) .trix-button--icon-code,
  trix-toolbar:not(.trix-chat trix-toolbar) .trix-button--icon-quote,
  trix-toolbar:not(.trix-chat trix-toolbar) .trix-button--icon-bullet-list,
  trix-toolbar:not(.trix-chat trix-toolbar) .trix-button--icon-number-list {
    display: none !important;
  }

  trix-toolbar:not(.trix-chat trix-toolbar) .trix-button-group {
    margin-bottom: 0.25rem;
  }

  html body trix-toolbar:not(.trix-chat trix-toolbar) .trix-button,
  html body trix-toolbar:not(.trix-chat trix-toolbar) .trix-button-group button.trix-button {
    width: 1.5rem !important;
    height: 1.5rem !important;
    min-width: 1.5rem !important;
    max-width: 1.5rem !important;
    min-height: 1.5rem !important;
    max-height: 1.5rem !important;
  }
}

/* Make sure chat editor toolbar overrides are properly applied */
.trix-chat trix-toolbar .trix-button::before {
  margin: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 65%;
}

/* Active button styling for all trix editors */
trix-toolbar .trix-button.trix-active {
  background-color: #e5e7eb;
  border-radius: 0.25rem;
}

/* Ensure Trix icons are visible for all editors */
trix-toolbar .trix-button-group button.trix-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Add a subtle hover effect for all editors */
trix-toolbar .trix-button:hover {
  background-color: #f3f4f6 !important;
}

/* Style the content display in chat messages */
.prose .trix-content {
  padding: 0 !important;
  margin: 0 !important;
}

/* Message styling */
.user-message {
  background-color: #f0f9ff;
  border-color: #bae6fd;
  align-self: flex-end;
}

.ai-message {
  background-color: #f5f5f4;
  border-color: #e7e5e4;
  align-self: flex-start;
}

/* Thread styling */
.thread-container {
  border-left: 3px solid #e5e7eb;
  margin-left: 1rem;
  padding-left: 0.75rem;
}

/* Hide scrollbar on mobile for better UX */
@media (max-width: 640px) {
  .overflow-y-auto::-webkit-scrollbar {
    display: none;
  }
  
  .overflow-y-auto {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
}

/* Fix iOS input zoom */
@media screen and (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}