:root {
  --primary-color: #2c3e50;
  --secondary-color: #34495e;
  --accent-color: #3498db;
  --background-color: #f5f5f5;
  --text-color: #333333;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--background-color);
  color: var(--text-color);
}

#app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 1fr;
  height: 100vh;
}

header {
  display: flex;
  height: 40px;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background-color: var(--primary-color);
  color: white;
  position: relative;
  z-index: 4;
}

header h1 {
  margin: 0;
}

nav ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
}

nav ul li {
  margin-right: 20px;
}

nav ul li a {
  color: white;
  text-decoration: none;
}

#notes-view {
  height: calc(100vh - 140px);
  overflow-y: auto;
  padding: 20px;
  width: calc(100% - 40px);
  transition: transform 0.3s ease, width 0.3s ease;
}

#notes-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  grid-gap: 20px;
}

.note {
  border: 1px solid #ccc;
  padding: 20px;
  background-color: var(--background-color);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  position: relative;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.note.show {
  opacity: 1 !important;
  transform: translateY(0);
}

.note.selected {
  background-color: #e0e0e0;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.1);
}

.note.selected.show {
  transform: translateY(10px) !important;
}

.note-actions {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.note:hover .note-actions {
  opacity: 1;
}

.note-actions button {
  margin-left: 10px;
  padding: 6px 12px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.note-actions button:hover {
  background-color: #0c87c5;
}

.note:hover {
  transform: translateY(10px) !important;
}

.note-text {
  font-size: 18px;
  margin-bottom: 10px;
  color: var(--text-color);
}

.note-tags {
  color: var(--secondary-color);
  font-size: 14px;
}

.highlight {
  background-color: yellow;
}

#settings {
  margin-top: 10px;
  display: flex;
  justify-content: flex-start;
}

#settings label {
  display: flex;
  align-items: center;
  font-size: 14px;
}

#settings input[type="checkbox"] {
  margin-right: 5px;
}

.chat-message {
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 10px;
  max-width: 80%;
}

.user-message {
  background-color: #2196f3;
  color: white;
  align-self: flex-end;
}

.assistant-message {
  background-color: #f1f1f1;
  color: #333;
  align-self: flex-start;
}

#chat-input-container {
  display: flex;
  margin-top: 10px;
}

#chat-input {
  flex: 1;
  padding: 5px;
}

.info-text {
  font-size: 12px;
  color: var(--secondary-color);
  margin-bottom: 10px;
}

#send-message,
#reset-chat {
  margin-left: 10px;
  padding: 8px 16px;
  background-color: var(--primary-color);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#send-question {
  width: 18%;
  padding: 5px;
}

#api-key-input {
  width: 300px;
  padding: 5px;
}

#api-key-container {
  display: flex;
}

#set-api-key {
  padding: 5px 10px;
  margin: 0px 10px;
}

#insights-container {
  margin-top: 20px;
}

#insights-output {
  margin-top: 10px;
  white-space: pre-wrap;
}

#note-selection {
  margin-top: 20px;
  margin-bottom: 20px;
}

#note-selection input[type="text"],
#note-selection select {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--secondary-color);
  border-radius: 4px;
}

#selected-notes {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 10px;
}

#summarization,
#insights {
  margin-bottom: 20px;
}

#summarization select,
#insights select {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--secondary-color);
  border-radius: 4px;
}

#insights-output {
  max-height: 200px;
  overflow-y: auto;
}

.selected-note {
  background-color: #f0f0f0;
}

.hidden {
  display: none;
}

#loading-spinner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 20px;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  z-index: 9999;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid #ccc;
  border-top-color: #333;
  animation: spin 1s infinite linear;
  margin: 0 auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.spinner-text {
  margin-top: 10px;
}

#error-message {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #f44336;
  color: white;
  padding: 10px;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.note-text {
  margin-bottom: 10px;
  padding: 5px;
  border: 1px solid transparent;
  outline: none;
}

.note-text[contenteditable="true"] {
  border-color: #ccc;
  background-color: #f9f9f9;
}

.note-tags[contenteditable="true"] {
  border-color: #ccc;
  background-color: #f9f9f9;
  padding: 5px;
  outline: none;
}

/* Dark mode styles */
body.dark-mode {
  --background-color: #14171a;
  --text-color: #ffffff;
}

body.dark-mode .note {
  background-color: #1c2938;
  box-shadow: 0 1px 3px rgba(255, 255, 255, 0.12), 0 1px 2px rgba(255, 255, 255, 0.24);
}

#toggle-flyout {
  padding: 10px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  z-index: 5;
}

#toggle-flyout:hover {
  background-color: #0c87c5;
}

#flyout-panel {
  position: fixed;
  top: 0;
  right: calc(-30vw - 40px);
  margin-top: 60px;
  width: 30vw;
  height: 100vh;
  background-color: var(--background-color);
  border-left: 1px solid var(--secondary-color);
  transition: right 0.3s ease;
  overflow-y: auto;
  z-index: 3;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

#flyout-panel.open {
  right: 0;
}

#chat-widget {
  position: fixed;
  bottom: 60px;
  right: 20px;
  z-index: 1000;
  transition: right 0.3s ease;
}

#chat-window {
  position: absolute;
  bottom: -20px;
  right: 0px;
  width: 300px;
  max-height: 400px;
  background-color: white;
  border: 1px solid var(--secondary-color);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  display: none;
}

#chat-messages {
  overflow-y: auto;
}

#chat-window.open {
  display: block;
}

#flyout-panel h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

#flyout-panel button:not(#toggle-dark-mode) {
  display: block;
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#flyout-panel button:hover {
  background-color: #0c87c5;
}

#toggle-dark-mode {
  display: inline-block;
  padding: 10px 20px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  margin-bottom: 20px;
  width: auto;
}

#toggle-dark-mode:hover {
  background-color: #0c87c5;
}

#select-notes-search {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--secondary-color);
  border-radius: 4px;
  box-sizing: border-box;
}

#toggle-chat {
  position: fixed;
  bottom: 0px;
  right: 20px;
  padding: 10px 20px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  z-index: 1000;
  transition: background-color 0.3s ease, transform 0.3s ease;
}

#toggle-chat:hover {
  background-color: #0c87c5;
}

#toggle-sort-search,
#collapse-btn {
  margin-right: 10px;
  height: 40px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#toggle-sort-search:hover {
  background-color: #0c87c5;
}

#footer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background-color: var(--primary-color);
  padding: 0 20px;
  z-index: 1000;
  width: 100%;
  transition: width 0.3s ease;
}

#footer-toolbar button {
  background-color: transparent;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 16px;
}

footer {
  transition: width 0.3s ease;
}

.toolbox {
  position: fixed;
  bottom: 40px;
  left: 0;
  right: 0;
  background-color: var(--background-color);
  border-top: 1px solid var(--secondary-color);
  padding: 20px;
  z-index: 999;
  display: none;
  width: calc(100% - 40px);
  transition: width 0.3s ease, transform 0.3s ease, bottom 0.3s ease;
}

.toolbox.open {
  display: block !important;
}

#toolbox-options {
  display: flex;
}

#toolbox-options button {
  margin-right: 10px;
}

#toolbox-tabs {
  display: flex;
  justify-content: left;
  margin-left: 20px;
}

.toolbox-tab {
  padding: 6px 12px;
  background-color: var(--background-color);
  color: var(--text-color);
  border: none;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  transition: background-color 0.3s ease;
  margin-right: 5px;
  font-size: 14px;
}

.toolbox-tab:hover {
  background-color: #e0e0e0;
}

.toolbox-tab.active {
  background-color: var(--primary-color);
  color: white;
}

#sort-search-container {
  display: flex;
  flex-direction: column;
}

#search-input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--secondary-color);
  border-radius: 4px;
  margin-bottom: 10px;
  box-sizing: border-box;
}

#tag-select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--secondary-color);
  border-radius: 4px;
  margin-bottom: 10px;
}

#toggle-toolbox {
  position: fixed;
  bottom: 20px;
  left: 20px;
  padding: 10px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.3s ease;
  z-index: 3;
}

#toggle-toolbox:hover {
  background-color: #0c87c5;
}

#toggle-toolbox.open {
  transform: translateY(calc(-20vh - 20px));
}

#toolbox-content {
  padding: 20px;
}

#add-note-toolbox {
  align-items: flex-start;
}

#note-input {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

#note-text {
  height: 50px;
  resize: vertical;
  margin-bottom: 10px;
}

#note-tags {
  margin-bottom: 10px;
}

#settings {
  align-items: center;
}

#settings label {
  margin-right: 10px;
}

#save-note {
  align-self: flex-start;
}