/* General container for the chat interface */
#chat-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    font-family: Arial, sans-serif;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
  }
  
  /* Chat history container */
  #history {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    border-bottom: 1px solid #ddd;
  }
  
  /* Input container */
  #input-container {
    display: flex;
    flex-direction: column;
    padding: 15px;
    gap: 10px;
  }
  
  /* Controls container */
  .controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Wrap if necessary */
  }
  
  /* Left-side controls (Model, Role, and Include History) */
  .left-controls {
    display: flex;
    align-items: center;
    gap: 15px; /* Space between each group */
  }
  
  /* Model selector container */
  .model-container {
    display: flex;
    align-items: center;
    gap: 5px;
  }
  
  #model-select {
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 5px;
  }
  
  /* Role container with label and dropdown */
  .role-container {
    display: flex;
    align-items: center;
    gap: 5px;
  }
  
  #role-select {
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 5px;
  }
  
  /* Include History checkbox */
  .include-history {
    display: flex;
    align-items: center;
    gap: 5px;
  }
  
  /* Send button aligned to the right */
  #send-button {
    margin-left: auto; /* Push the button to the right */
    padding: 10px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
  }
  
  #send-button:disabled {
    background: #aaa;
    cursor: not-allowed;
  }
  
  /* Textarea for prompts */
  #prompt-input {
    resize: vertical;
    height: 80px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-family: inherit;
    font-size: 14px;
  }
  
  /* File input */
  #image-input {
    margin-bottom: 10px;
  }
  
  .chat-entry {
    padding: 10px;
    border: 1px solid transparent; /* Default border for no hover */
    margin-bottom: 10px;
    position: relative;
  }
  
  .chat-entry:hover {
    border: 1px dotted #007bff; /* Dotted border on hover */
    cursor: pointer;
  }
  
  .chat-entry .delete-popup {
    display: none;
    position: absolute;
    background-color: white;
    border: 1px solid #ccc;
    padding: 10px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
    z-index: 10;
  }
  
  .chat-entry.show-popup .delete-popup {
    display: block;
  }

  .response {
    background-color: #f8f9fa; /* Light gray background */
    border: 1px solid #ddd;   /* Light border */
    border-radius: 5px;       /* Rounded corners */
    padding: 10px;            /* Padding inside the block */
    font-family: monospace;   /* Fixed-width font */
    white-space: pre-wrap;    /* Preserve formatting and allow wrapping */
    word-wrap: break-word;    /* Ensure long words wrap correctly */
  }

  .info-message {
    color: #888;
    font-size: 12px;
    margin-top: 5px;
    font-style: italic;
  }

#history-controls {
    display: flex;
    align-items: center;
    margin-top: 15px; /* Add spacing above the row */
    gap: 10px; /* Add spacing between buttons */
  }
  
  #history-controls span {
    font-weight: bold;
  }
  
  #history-controls button {
    padding: 5px 10px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
  }
  
  #history-controls button:hover {
    background-color: #0056b3;
  }
  
  #history-controls button:disabled {
    background-color: #aaa;
    cursor: not-allowed;
  }
  
  .chat-entry.external {
    background-color: #f0f8ff; /* Light blue for external entries */
}

/* Base icon styling */
.toggle-icon {
  position: absolute;
  font-size: 16px;
  top: 8px; /* Keep it in front of the section */
  left: -24px; /* Keep it within the section */
  background: white;
  border-radius: 50%;
  padding: 3px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 10; /* Ensure it stays on top */
}

/* Individual icons */
.prompt-icon::before { content: "❓"; color: #dc3545; } /* Red */
.thinking-icon::before { content: "💡"; color: #f39c12; } /* Orange */
.response-icon::before { content: "✅"; color: #28a745; } /* Green */

/* Hide collapsed content */
.collapsible-content {
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
  overflow: hidden;
  opacity: 1;
}

/* Collapsed state */
.collapsed {
  max-height: 0 !important;
  opacity: 0;
  padding: 0;
  margin: 0;
  height: 8px;
}

/* Positioning wrappers */
.prompt-wrapper,
.thinking-wrapper,
.response-wrapper {
  position: relative;
  margin-bottom: 8px;
}

/* Prompt Box */
.prompt-box {
  position: relative;
  background-color: #fff3cd;
  border: 1px solid #ffeeba;
  border-radius: 5px;
  padding: 10px;
  font-family: monospace;
  white-space: pre-wrap;
  word-wrap: break-word;
  padding-left: 35px; /* Space for icon */
}

/* Thinking Box */
.thinking-box {
  position: relative;
  background-color: #d9edf7;
  border: 1px solid #bce8f1;
  padding: 8px;
  border-radius: 4px;
  margin: 8px 0;
  display: block;
  font-family: monospace;
  white-space: pre-wrap;
  padding-left: 35px; /* Space for icon */
}

/* Response Box */
.response {
  position: relative;
  background-color: #d4edda;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 10px;
  font-family: monospace;
  white-space: pre-wrap;
  word-wrap: break-word;
  padding-left: 35px; /* Space for icon */
}

/* Image toggle icon */
.image-icon::before {
  content: "🖼️"; /* Image icon */
  color: #6c757d; /* Gray */
}

/* Image wrapper */
.image-wrapper {
  position: relative;
  margin-top: 8px;
}

/* Image container starts expanded */
.image-container {
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
  max-height: 1000px;
  opacity: 1;
}

/* Collapsed state */
.collapsed {
  max-height: 0 !important;
  opacity: 0;
  padding: 0;
  margin: 0;
}

/* Pulsating animation for the thinking box */
@keyframes pulsate {
  0% {
    box-shadow: 0 0 0 0 rgba(91, 192, 222, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(91, 192, 222, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(91, 192, 222, 0);
  }
}

.pulsating {
  animation: pulsate 1.5s infinite;
}

/* Modal container (overlay) */
.modal {
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent dark overlay */
  align-items: center;  /* Centers modal vertically */
  justify-content: center;  /* Centers modal horizontally */
}

/* Modal content container */
.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 75vw;
  height: 75vh;
  background-color: #ffffe0;  /* Light yellow background */
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* Modal body: holds all the text and input elements and is scrollable */
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex-grow: 1;
}

/* Modal buttons: pinned to the bottom */
.modal-buttons {
  padding: 10px;
  background-color: #e9e9e9; /* A light grey background for the button area */
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

.modal-buttons button {
  padding: 8px 16px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

#save-base-url {
  background-color: #007bff;
  color: white;
}

#cancel-base-url {
  background-color: #aaa;
  color: white;
}
