/* YL Ai General Chat — ChatGPT-style UI */

.tools-yl-ai-page {
  min-height: 100vh;
  overflow: hidden;
  padding-top: var(--header-height, 72px);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) rgba(12, 12, 14, 0.95);
}

.tools-yl-ai-page ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.tools-yl-ai-page ::-webkit-scrollbar-track {
  background: rgba(12, 12, 14, 0.95);
}

.tools-yl-ai-page ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  border: 2px solid rgba(12, 12, 14, 0.95);
}

.tools-yl-ai-page ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.tools-yl-ai-page ::-webkit-scrollbar-corner {
  background: rgba(12, 12, 14, 0.95);
}

.site-header--tools {
  background: rgba(5, 5, 5, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tools-yl-ai-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(8, 8, 10, 0.92) 0%, rgba(8, 8, 10, 0.88) 100%),
    url('/assets/backgrounds/cover-photo.png') center / cover no-repeat;
}

.tools-yl-ai-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 72px);
  max-width: 1400px;
  margin: 0 auto;
  gap: 0;
}

.tools-yl-ai-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 12, 14, 0.85);
  backdrop-filter: blur(12px);
  min-height: 0;
}

.tools-yl-ai-sidebar__header {
  flex-shrink: 0;
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tools-yl-ai-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(214, 0, 0, 0.45);
  border-radius: 8px;
  background: rgba(214, 0, 0, 0.18);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.tools-yl-ai-new-chat:hover {
  background: rgba(214, 0, 0, 0.28);
  border-color: rgba(214, 0, 0, 0.65);
}

.tools-yl-ai-new-chat__icon {
  font-size: 1.15rem;
  line-height: 1;
  font-weight: 700;
}

.tools-yl-ai-thread-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  min-height: 0;
}

.tools-yl-ai-thread {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.85rem;
  transition: background 0.15s;
}

.tools-yl-ai-thread:hover {
  background: rgba(255, 255, 255, 0.06);
}

.tools-yl-ai-thread.is-active {
  background: rgba(214, 0, 0, 0.18);
  color: #fff;
}

.tools-yl-ai-thread__title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tools-yl-ai-thread__rename {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.tools-yl-ai-thread:hover .tools-yl-ai-thread__rename {
  opacity: 1;
}

.tools-yl-ai-thread__rename:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.tools-yl-ai-thread__delete {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.tools-yl-ai-thread:hover .tools-yl-ai-thread__delete {
  opacity: 1;
}

.tools-yl-ai-thread__delete:hover {
  background: rgba(214, 0, 0, 0.25);
  color: #fff;
}

.tools-yl-ai-sidebar__footer {
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.4;
}

.tools-yl-ai-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(8, 8, 10, 0.55);
}

.tools-yl-ai-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 12, 14, 0.65);
}

.tools-yl-ai-toolbar .tools-yl-ai-new-chat {
  width: auto;
  min-width: 140px;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
}

.tools-yl-ai-thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 12, 14, 0.55);
}

.tools-yl-ai-thread-header__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tools-yl-ai-thread-header__actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.tools-yl-ai-thread-header__btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
}

.tools-yl-ai-thread-header__btn:hover {
  background: rgba(214, 0, 0, 0.15);
  border-color: rgba(214, 0, 0, 0.35);
}

.tools-yl-ai-thread-header__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tools-yl-ai-thread-header__btn:disabled:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}

.tools-yl-ai-thread-header__btn--primary {
  background: rgba(214, 0, 0, 0.22);
  border-color: rgba(214, 0, 0, 0.55);
  color: #fff;
  font-weight: 600;
}

.tools-yl-ai-thread-header__btn--primary:hover {
  background: rgba(214, 0, 0, 0.35);
  border-color: rgba(214, 0, 0, 0.75);
}

.tools-yl-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1rem 2rem;
  min-height: 0;
}

.tools-yl-ai-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: rgba(255, 255, 255, 0.55);
  gap: 0.75rem;
}

.tools-yl-ai-empty__title {
  font-size: 1.5rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
  margin: 0;
}

.tools-yl-ai-empty__subtitle {
  margin: 0;
  font-size: 0.95rem;
  max-width: 420px;
}

.tools-yl-ai-message {
  display: flex;
  gap: 1rem;
  max-width: 820px;
  margin: 0 auto 1.25rem;
  padding: 0 0.5rem;
}

.tools-yl-ai-message__avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.tools-yl-ai-message--user .tools-yl-ai-message__avatar {
  background: rgba(214, 0, 0, 0.35);
  color: #ffe0e0;
}

.tools-yl-ai-message--assistant .tools-yl-ai-message__avatar {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.85);
}

.tools-yl-ai-message__body {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.9);
  white-space: pre-wrap;
  word-break: break-word;
}

.tools-yl-ai-message--user .tools-yl-ai-message__body {
  color: rgba(255, 255, 255, 0.95);
}

.tools-yl-ai-ollama-banner {
  max-width: 820px;
  margin: 0 auto 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
  background: rgba(255, 180, 0, 0.14);
  border: 1px solid rgba(255, 180, 0, 0.4);
  color: #ffe8a3;
}

.tools-yl-ai-ollama-banner[hidden] {
  display: none;
}

.tools-yl-ai-ollama-banner code,
.tools-yl-ai-ollama-banner__hint {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: rgba(255, 232, 163, 0.92);
}

.tools-yl-ai-ollama-banner code {
  background: rgba(0, 0, 0, 0.25);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}

.tools-yl-ai-ollama-banner--cpu {
  background: rgba(255, 140, 0, 0.12);
  border-color: rgba(255, 140, 0, 0.45);
}

.tools-yl-ai-composer {
  padding: 1rem 1.25rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 12, 14, 0.75);
}

.tools-yl-ai-composer__inner {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.tools-yl-ai-composer__input {
  flex: 1;
  min-height: 24px;
  max-height: 200px;
  resize: none;
  border: none;
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  outline: none;
}

.tools-yl-ai-composer__input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.tools-yl-ai-composer__send {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: var(--accent, #d60000);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, transform 0.1s;
}

.tools-yl-ai-composer__send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tools-yl-ai-composer__send:not(:disabled):hover {
  transform: scale(1.05);
}

.tools-yl-ai-composer__hint {
  max-width: 820px;
  margin: 0.5rem auto 0;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.35);
  text-align: center;
}

.tools-yl-ai-status {
  max-width: 820px;
  margin: 0 auto 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  display: none;
}

.tools-yl-ai-status.is-visible {
  display: block;
}

.tools-yl-ai-status--error {
  background: rgba(214, 0, 0, 0.15);
  border: 1px solid rgba(214, 0, 0, 0.35);
  color: #ffcaca;
}

.tools-yl-ai-status--info {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.75);
}

.tools-yl-ai-status--warning {
  background: rgba(255, 180, 0, 0.12);
  border: 1px solid rgba(255, 180, 0, 0.35);
  color: #ffe8a3;
}

.tools-yl-ai-message--thinking .tools-yl-ai-message__body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: rgba(255, 255, 255, 0.55);
}

.tools-yl-ai-thinking-label {
  font-size: 0.88rem;
  font-style: italic;
  color: rgba(255, 255, 255, 0.6);
}

.tools-yl-ai-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 0.25rem 0;
}

.tools-yl-ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  animation: yl-ai-bounce 1.2s infinite ease-in-out;
}

.tools-yl-ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.tools-yl-ai-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes yl-ai-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 768px) {
  .tools-yl-ai-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 72px);
  }

  .tools-yl-ai-sidebar {
    max-height: none;
    min-height: 148px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .tools-yl-ai-thread-list {
    max-height: 88px;
  }

  .tools-yl-ai-main {
    min-height: 60vh;
  }
}
