:root {
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  font-weight: 400;

  color-scheme: light dark;
  color: rgba(255, 255, 255, 0.87);
  background-color: #242424;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  font-weight: 500;
  color: #646cff;
  text-decoration: inherit;
}
a:hover {
  color: #535bf2;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-width: 320px;
  min-height: 100vh;
  height: 100vh;
}

h1 {
  font-size: 3.2em;
  line-height: 1.1;
}

#app {
  max-width: 90%;
  margin: 0 auto;
  padding: 2rem;
  text-align: center;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.logo {
  height: 6em;
  padding: 1.5em;
  will-change: filter;
  transition: filter 300ms;
}
.logo:hover {
  filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.vanilla:hover {
  filter: drop-shadow(0 0 2em #f7df1eaa);
}

.card {
  padding: 2em;
}

.read-the-docs {
  color: #888;
}

/* Button styling - combining both versions */
button,
.button {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.6em 1.2em;
  font-size: 1em;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s;
}

.button {
  padding: 10px 20px;
  margin: 5px;
  border-radius: 4px;
  background-color: #4caf50;
  color: white;
}

.button:hover {
  background-color: #45a049;
}

button:hover {
  border-color: #646cff;
}
button:focus,
button:focus-visible {
  outline: 4px auto -webkit-focus-ring-color;
}

button:disabled,
.button:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
  opacity: 0.7;
}

/* Status styling */
#status {
  padding: 10px;
  margin: 10px;
  border-radius: 4px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.connected {
  background-color: #dff0d8;
  color: #3c763d;
}

.disconnected {
  background-color: #f1d79d;
  color: #8a6d3b;
}

.error {
  background-color: #fcf8e3;
  color: #a94442;
}

/* Chat container styling */
#chat-container {
  flex: 1;
  overflow-y: auto;
  border: 1px solid #ccc;
  margin: 10px;
  padding: 10px;
  border-radius: 4px;
  margin-bottom: 80px; /* Space for controls */
  display: flex;
  flex-direction: column;
}

/* Message styling */

.message {
  margin: 10px 0;
  padding: 12px;
  border-radius: 12px;
  position: relative;
  max-width: 70%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  word-wrap: break-word;
}

.message:hover {
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.user {
  background-color: #e3f2fd; /* Pastel light blue */
  color: #333;
  align-self: flex-end; /* Align to right */
  border-bottom-right-radius: 3px; /* Bubble shape */
  margin-left: auto;
}

.assistant {
  background-color: #fce4ec; /* Pinkish */
  color: #333;
  align-self: flex-start; /* Align to left */
  border-bottom-left-radius: 3px; /* Bubble shape */
  margin-right: auto;
}

.system {
  background-color: #fff3e0;
  color: #666;
  font-style: italic;
  max-width: 90%;
  align-self: center; /* Center system messages */
  text-align: center;
  font-size: 0.9em;
}

.role-label {
  font-size: 0.75em;
  color: #666;
  margin-bottom: 4px;
  font-weight: bold;
}

.conversation-end {
  background-color: rgba(245, 245, 245, 0.7);
  color: #666;
  font-style: italic;
  padding: 8px 15px;
  border-radius: 20px;
  margin: 15px auto;
  text-align: center;
  max-width: 60%;
  font-size: 0.9em;
}

.message-content {
  line-height: 1.4;
}

/* Controls styling */
#controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 15px;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: center;
  gap: 10px;
  z-index: 100;
}

/* Dark/light mode adaptations */
@media (prefers-color-scheme: dark) {
  #chat-container {
    background-color: #1e1e1e;
    border-color: #333;
  }

  .user {
    background-color: #2c3e50;
    color: #e4e4e4;
  }

  .assistant {
    background-color: #4a235a;
    color: #e4e4e4;
  }

  .system {
    background-color: #2d3436;
    color: #b2bec3;
  }

  .conversation-end {
    background-color: rgba(45, 45, 45, 0.7);
    color: #b2bec3;
  }

  #controls {
    background-color: #242424;
  }

  .role-label {
    color: #b2bec3;
  }

  .connected {
    background-color: #264d33;
    color: #a5d6a7;
  }

  .disconnected {
    background-color: #4d3d26;
    color: #ffe082;
  }

  .error {
    background-color: #4d2626;
    color: #ef9a9a;
  }
}

@media (prefers-color-scheme: light) {
  :root {
    color: #213547;
    background-color: #ffffff;
  }
  a:hover {
    color: #747bff;
  }
  button {
    background-color: #f9f9f9;
  }

  #chat-container {
    background-color: #f9f9f9;
  }

  #controls {
    background-color: white;
  }
}

/* Media Queries for Responsiveness */
@media (max-width: 768px) {
  .message {
    max-width: 85%;
  }

  .button,
  button {
    padding: 8px 16px;
    font-size: 14px;
  }

  #app {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .message {
    max-width: 90%;
  }

  #chat-container {
    margin: 5px;
    padding: 8px;
    margin-bottom: 70px;
  }

  .button,
  button {
    padding: 8px 12px;
    font-size: 13px;
  }

  #app {
    padding: 0.5rem;
  }
}
/* system prompt editor */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  margin-bottom: 10px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timer-container {
  display: flex;
  align-items: center;
  gap: 5px;
}

.button-container {
  display: flex;
  gap: 5px;
}

#system-prompt-container {
  margin: 10px;
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 20px;
  background-color: #fff3e0;
  transition: all 0.3s ease;
  border: 1px solid #ccc;
}

#system-prompt-container h2 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.2em;
}

.editor-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.system-prompt-textarea {
  width: 100%;
  min-height: 200px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: monospace;
  font-size: 14px;
  resize: vertical;
}

.prompt-controls {
  display: flex;
  justify-content: flex-end;
}

#save-confirmation {
  color: #4caf50;
  font-weight: bold;
  padding: 5px;
  margin-bottom: 10px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  #system-prompt-container {
    background-color: #2d3436;
    color: #b2bec3;
  }

  .system-prompt-textarea {
    background-color: #1e1e1e;
    color: #e4e4e4;
    border-color: #333;
  }

  #save-confirmation {
    color: #a5d6a7;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-controls {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    margin-top: 10px;
  }

  .button-container {
    width: 100%;
    justify-content: space-between;
  }

  .system-prompt-textarea {
    min-height: 150px;
  }
}
