: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;

  /* Authentication UI variables */
  --bg-primary: #242424;
  --bg-secondary: #333333;
  --text-primary: rgba(255, 255, 255, 0.87);
  --text-secondary: rgba(255, 255, 255, 0.6);
  --border: #444444;
  --accent: #646cff;
  --accent-hover: #535bf2;
  --error: #ff6b6b;
  --error-bg: rgba(255, 107, 107, 0.1);
}

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: 100vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.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;
}

.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;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* 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;
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 20px;
  margin-left: 5px;
  vertical-align: middle;
}

.thinking-text {
  display: inline-block;
  margin-right: 4px;
  font-style: italic;
}

.thinking-dots .dot {
  width: 8px;
  height: 8px;
  background-color: #888;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 1.5s infinite ease-in-out;
}

.message.user .thinking-dots .dot {
  background-color: #4a76fd;
}

.message.assistant .thinking-dots .dot {
  background-color: #fd7e4a;
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 20px;
  margin-left: 5px;
  vertical-align: middle;
}

.thinking-text {
  display: inline-block;
  margin-right: 4px;
  font-style: italic;
}

.thinking-dots .dot {
  width: 8px;
  height: 8px;
  background-color: #888;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 1.5s infinite ease-in-out;
}

.message.user .thinking-dots .dot {
  background-color: #4a76fd;
}

.message.assistant .thinking-dots .dot {
  background-color: #fd7e4a;
}

.thinking-dots .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-dots .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(0.7);
    opacity: 0.5;
  }

  50% {
    transform: scale(1);
    opacity: 1;
  }
}

.message.thinking {
  opacity: 0.7;
}

/* Controls styling */
#controls {
  padding: 15px;
  border-top: 1px solid #ccc;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
}

/* 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 {
    border-top-color: #333;
  }

  .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;

    /* Authentication UI variables for light mode */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-primary: #213547;
    --text-secondary: #6c757d;
    --border: #dee2e6;
    --accent: #646cff;
    --accent-hover: #535bf2;
    --error: #dc3545;
    --error-bg: rgba(220, 53, 69, 0.1);
  }

  a:hover {
    color: #747bff;
  }

  button {
    background-color: #f9f9f9;
  }

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

  #controls {
    border-top-color: #dee2e6;
  }
}

/* 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;
  }

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

  #app {
    padding: 0.5rem;
  }
}

/* Tool Debug Interface Styles */
.tool-debug-container {
    margin-top: 8px;
    border-top: 1px solid #e0e0e0;
    padding-top: 8px;
}

.tool-debug-toggle {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    color: #666;
    transition: background-color 0.2s ease;
}

.tool-debug-toggle:hover {
    background: #e8e8e8;
}

.tool-debug-details {
    margin-top: 8px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px;
    font-size: 11px;
}

.tool-debug-item {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.tool-debug-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.tool-debug-item pre {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 2px;
    padding: 4px;
    margin: 4px 0;
    overflow-x: auto;
    font-size: 10px;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.tool-debug-item strong {
    color: #333;
    font-weight: 600;
}

.tool-debug-item small {
    color: #888;
    font-style: italic;
}

/* Dark mode styles for tool debug interface */
@media (prefers-color-scheme: dark) {
    .tool-debug-container {
        border-top-color: #444;
    }

    .tool-debug-toggle {
        background: #333;
        border-color: #555;
        color: #ccc;
    }

    .tool-debug-toggle:hover {
        background: #444;
    }

    .tool-debug-details {
        background: #2a2a2a;
        border-color: #444;
        color: #ccc;
    }

    .tool-debug-item {
        border-bottom-color: #444;
    }

    .tool-debug-item pre {
        background: #1e1e1e;
        border-color: #555;
        color: #e0e0e0;
    }

    .tool-debug-item strong {
        color: #fff;
    }

    .tool-debug-item small {
        color: #aaa;
    }
}