/* public/styles.css */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #282a36;
  --bg-secondary: #21222c;
  --bg-tertiary: #44475a;
  --text-primary: #f8f8f2;
  --text-secondary: #6272a4;
  --accent: #bd93f9;
  --accent-hover: #ff79c6;
  --border: #44475a;
  --error: #f55;
  --user-msg-bg: #bd93f9;
  --assistant-msg-bg: #44475a;
  --cyan: #8be9fd;
  --green: #50fa7b;
  --orange: #ffb86c;
  --pink: #ff79c6;
  --purple: #bd93f9;
  --yellow: #f1fa8c;
}

html, body {
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, sans-serif;
}

#app, .view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  width: 280px;
  min-width: 220px;
  max-width: 360px;
}

.sidebar-header {
  display: flex;
  border-bottom: 1px solid var(--border);
  justify-content: space-between;
  align-items:  center;
  gap: .75rem;
  padding: .75rem;
}

.sidebar-title {
  color: var(--text-primary);
  font-weight: 600;
}

.sidebar-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 6px;
  padding: .4rem .6rem;
}

.sidebar-btn:hover {
  border-color: var(--accent);
}

.conversation-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding: .5rem;
}

.conversation-item {
  text-align: left;
  color: var(--text-primary);
  cursor: pointer;
  background: none;
  border: 1px solid #0000;
  border-radius: 8px;
  width: 100%;
  padding: .6rem .7rem;
}

.conversation-item:hover {
  border-color: var(--border);
  background: #ffffff08;
}

.conversation-item.active {
  border-color: var(--accent);
  background: #bd93f91f;
}

.conversation-item .title {
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.2;
}

.conversation-item .meta {
  color: var(--text-secondary);
  margin-top: .2rem;
  font-size: .75rem;
}

.chat-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

@media (width <= 820px) {
  .sidebar {
    display: none;
  }
}

.hidden {
  display: none !important;
}

.login-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: center;
  align-items:  center;
  padding: 2rem;
}

.login-container h1 {
  background: linear-gradient(135deg, var(--purple), var(--pink));
  -webkit-text-fill-color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  margin-bottom: .5rem;
  font-size: 3rem;
  font-weight: 700;
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 320px;
}

#login-form input {
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  border-radius: 8px;
  padding: .875rem 1rem;
  transition: border-color .2s;
  font-size: 1rem;
}

#login-form input:focus {
  border-color: var(--accent);
}

#login-form button {
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: .875rem 1rem;
  transition: background .2s;
  font-size: 1rem;
  font-weight: 600;
}

#login-form button:hover {
  background: var(--accent-hover);
}

.error {
  color: var(--error);
  text-align: center;
  min-height: 1.25rem;
  font-size: .875rem;
}

.chat-header {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  justify-content: space-between;
  align-items:  center;
  padding: 1rem 1.5rem;
}

.chat-header .header-left {
  display: flex;
  align-items:  center;
  gap: 2rem;
}

.chat-header h1 {
  background: linear-gradient(135deg, var(--purple), var(--pink));
  -webkit-text-fill-color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  font-size: 1.25rem;
  font-weight: 600;
}

.nav-tabs {
  display: flex;
  gap: .5rem;
}

.nav-tab {
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  padding: .5rem 1rem;
  transition: all .2s;
  font-size: .875rem;
}

.nav-tab:hover, .nav-tab.active {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.logout-btn {
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  background: none;
  border-radius: 6px;
  padding: .5rem 1rem;
  transition: all .2s;
  font-size: .875rem;
}

.logout-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.alert-banner {
  display: flex;
  border: 1px solid var(--border);
  color: var(--text-primary);
  background: #8be9fd1f;
  border-radius: 8px;
  justify-content: space-between;
  align-items:  center;
  gap: 1rem;
  margin: 1rem 1.5rem 0;
  padding: .75rem 1rem;
}

.alert-banner button {
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 6px;
  padding: .35rem .75rem;
}

.alert-banner button:hover {
  border-color: var(--accent);
}

.status-panel {
  display: flex;
  border: 1px dashed var(--border);
  color: var(--text-secondary);
  border-radius: 8px;
  align-items:  center;
  gap: .5rem;
  margin: .75rem 1.5rem 0;
  padding: .5rem 1rem;
  font-size: .85rem;
}

.messages {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 1rem;
  padding: 1.5rem;
}

.message {
  white-space: pre-wrap;
  word-wrap: break-word;
  border-radius: 12px;
  max-width: 80%;
  padding: .875rem 1rem;
  line-height: 1.5;
}

.message.user {
  background: var(--user-msg-bg);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self:  flex-end;
}

.message.assistant {
  background: var(--assistant-msg-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  align-self:  flex-start;
}

.message.assistant.streaming:after {
  content: "▋";
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 50% {
    opacity: 1;
  }

  51%, 100% {
    opacity: 0;
  }
}

.message.thinking {
  display: flex;
  color: var(--text-secondary);
  align-items:  center;
  gap: .25rem;
  font-style: italic;
}

.thinking-text {
  color: var(--cyan);
}

.thinking-dots:after {
  content: "";
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0%, 20% {
    content: "";
  }

  40% {
    content: ".";
  }

  60% {
    content: "..";
  }

  80%, 100% {
    content: "...";
  }
}

.thinking-block {
  background: var(--bg-primary);
  border-left: 3px solid var(--cyan);
  border-radius: 4px;
  margin-bottom: .75rem;
  padding: .75rem;
  font-size: .875rem;
}

.thinking-label {
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .5rem;
  font-size: .75rem;
  font-weight: 600;
}

.thinking-content {
  color: var(--text-secondary);
  white-space: pre-wrap;
  font-style: italic;
}

.response-content {
  white-space: pre-wrap;
}

.chat-input-container {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  gap: .75rem;
  padding: 1rem 1.5rem;
}

#chat-input {
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  resize: none;
  outline: none;
  border-radius: 8px;
  flex: 1;
  max-height: 150px;
  padding: .75rem 1rem;
  transition: border-color .2s;
  font-family: inherit;
  font-size: 1rem;
}

#chat-input:focus {
  border-color: var(--accent);
}

#send-btn {
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: .75rem 1.5rem;
  transition: background .2s;
  font-size: 1rem;
  font-weight: 600;
}

#send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

#send-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.message code {
  color: var(--cyan);
  background: #282a36;
  border-radius: 4px;
  padding: .125rem .375rem;
  font-family: Fira Code, SF Mono, Monaco, Cascadia Code, monospace;
  font-size: .875em;
}

.message pre {
  overflow-x: auto;
  border: 1px solid var(--border);
  background: #282a36;
  border-radius: 6px;
  margin: .5rem 0;
  padding: .75rem;
}

.message pre code {
  color: var(--text-primary);
  background: none;
  padding: 0;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-secondary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--purple);
}

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

  .chat-header {
    padding: .875rem 1rem;
  }

  .alert-banner {
    margin: .75rem 1rem 0;
  }

  .status-panel {
    margin: .5rem 1rem 0;
  }

  .messages {
    padding: 1rem;
  }

  .chat-input-container {
    padding: .875rem 1rem;
  }
}
