/* Try front page theme - reversible via docs/dev-ops/nginx/rollback_try.sh */
:root {
  --try-bg: #ffffff;
  --try-surface: #ffffff;
  --try-muted: #f4f4f5;
  --try-muted-2: #fafafa;
  --try-border: #e5e7eb;
  --try-text: #111827;
  --try-subtle: #6b7280;
  --try-accent: #111827;
  --try-radius: 18px;
}

html, body {
  background: var(--try-bg) !important;
  color: var(--try-text);
}

body > nav {
  background: rgba(255, 255, 255, .92) !important;
  border-bottom: 1px solid var(--try-border) !important;
  box-shadow: none !important;
  backdrop-filter: blur(14px);
}

body > nav::before {
  content: "Try";
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--try-text);
  margin-right: .25rem;
  font-size: 1.05rem;
}

button, select, textarea, a {
  transition: border-color .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease !important;
}

#newChatBtn,
#clearAllChatsBtn,
#uploadMenuButton,
a[href="admin/index.html"] {
  background: #fff !important;
  color: var(--try-text) !important;
  border: 1px solid var(--try-border) !important;
  box-shadow: none !important;
  border-radius: 12px !important;
  font-weight: 500 !important;
}

#clearAllChatsBtn { color: #9f1239 !important; }
#newChatBtn:hover,
#clearAllChatsBtn:hover,
#uploadMenuButton:hover,
a[href="admin/index.html"]:hover {
  background: var(--try-muted) !important;
  transform: translateY(-1px);
}

#aiAgent, #ragSelect, #promptSelect {
  background: #fff !important;
  border: 1px solid var(--try-border) !important;
  border-radius: 12px !important;
  color: var(--try-text) !important;
  box-shadow: none !important;
}

#sidebar {
  background: #fbfbfb !important;
  border-right: 1px solid var(--try-border) !important;
  box-shadow: none !important;
}

#sidebar h2 {
  color: var(--try-subtle) !important;
  font-size: .82rem !important;
  font-weight: 600 !important;
  letter-spacing: .01em;
}

#chatList .chat-item,
.chat-item {
  border-radius: 12px !important;
  border: 1px solid transparent;
  background: transparent !important;
}

#chatList .chat-item:hover,
.chat-item:hover {
  background: #f4f4f5 !important;
}

#chatList .bg-blue-50 {
  background: #eeeeef !important;
  border-color: #e5e7eb !important;
}

#chatArea {
  background: #fff !important;
  padding-bottom: 12px !important;
}

#chatArea > .try-message-row {
  width: 100%;
  max-width: 860px;
  margin: 0 auto 18px auto;
  display: flex;
}

#chatArea > .try-message-row.try-user-row { justify-content: flex-end; }
#chatArea > .try-message-row.try-assistant-row { justify-content: flex-start; }

.try-message-bubble {
  position: relative;
  line-height: 1.75;
  font-size: 15px;
  color: var(--try-text);
  word-break: break-word;
}

.try-user-bubble {
  max-width: min(76%, 680px);
  background: #f1f1f2;
  border: 1px solid #ebebed;
  border-radius: 18px;
  padding: 14px 44px 14px 16px;
}

.try-assistant-bubble {
  width: 100%;
  background: #fff;
  border: 1px solid transparent;
  border-radius: 0;
  padding: 8px 44px 8px 2px;
}

.try-assistant-bubble p,
.try-user-bubble p {
  margin: 0 0 .85rem 0;
}
.try-assistant-bubble p:last-child,
.try-user-bubble p:last-child { margin-bottom: 0; }

.try-copy-btn {
  position: absolute;
  right: 8px;
  top: 8px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--try-border);
  background: rgba(255,255,255,.88);
  color: var(--try-subtle);
  font-size: 12px;
  line-height: 1.2;
  opacity: 0;
}

.try-message-bubble:hover .try-copy-btn,
.try-copy-btn:focus {
  opacity: 1;
}

.try-copy-btn:hover {
  background: #f4f4f5;
  color: var(--try-text);
}

.try-status {
  color: var(--try-subtle);
  font-size: 13px;
  padding: 6px 0;
}

#welcomeMessage > div {
  box-shadow: none !important;
  border: 1px solid var(--try-border) !important;
  border-radius: 24px !important;
  transform: none !important;
  background: #fff !important;
}

#welcomeMessage h3 {
  letter-spacing: -0.03em;
  color: var(--try-text) !important;
}

#welcomeMessage button,
#submitBtn {
  background: #111827 !important;
  color: #fff !important;
  border-radius: 999px !important;
  box-shadow: none !important;
  font-weight: 550 !important;
}

#welcomeMessage button:hover,
#submitBtn:hover {
  background: #27272a !important;
}

.input-container {
  border: 1px solid var(--try-border) !important;
  border-radius: 22px !important;
  box-shadow: 0 12px 40px rgba(0,0,0,.05) !important;
  background: #fff !important;
}

#messageInput {
  min-height: 92px !important;
  border-radius: 22px 22px 0 0 !important;
  box-shadow: none !important;
}

#messageInput:focus,
#aiAgent:focus,
#ragSelect:focus,
#promptSelect:focus {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(17,24,39,.08) !important;
  border-color: #d4d4d8 !important;
}

.markdown-body pre {
  border-radius: 14px;
  border: 1px solid var(--try-border);
  background: #f7f7f8 !important;
}

.markdown-body code {
  border-radius: 6px;
}

@media (max-width: 768px) {
  body > nav { gap: .5rem !important; }
  body > nav::before { display: none; }
  #chatArea > .try-message-row { max-width: 100%; }
  .try-user-bubble { max-width: 88%; }
  .try-copy-btn { opacity: 1; }
}


/* Mobile responsive layout patch: keep desktop unchanged, optimize screens <= 768px. */
html, body {
  margin: 0;
  min-height: 100%;
}
body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
body > nav {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
}
body > nav + div {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
}
#chatArea {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
#sidebar.-translate-x-full {
  transform: translateX(-100%);
}

@media (max-width: 768px) {
  body { height: 100dvh; }

  body > nav {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 10px !important;
    background: rgba(255,255,255,.96) !important;
  }

  body > nav::before {
    content: "Try" !important;
    display: block !important;
    order: 2;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0 !important;
    font-size: 17px !important;
    font-weight: 650 !important;
    color: var(--try-text, #111827) !important;
  }

  #toggleSidebar { order: 1; }
  #newChatBtn { order: 3; }
  #clearAllChatsBtn { order: 4; }
  body > nav > div:nth-of-type(2) { order: 5; }
  body > nav > a[href="admin/index.html"] { order: 6; }
  body > nav > div:nth-of-type(1) { order: 10; }

  #toggleSidebar,
  #newChatBtn,
  #clearAllChatsBtn,
  #uploadMenuButton,
  body > nav > a[href="admin/index.html"] {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 12px !important;
    font-size: 0 !important;
    white-space: nowrap !important;
  }

  #toggleSidebar svg,
  #newChatBtn svg,
  #clearAllChatsBtn svg,
  #uploadMenuButton svg,
  body > nav > a[href="admin/index.html"] svg {
    width: 20px !important;
    height: 20px !important;
    margin: 0 !important;
    flex: 0 0 auto !important;
  }

  #uploadMenuButton svg:last-child { display: none !important; }

  body > nav > div:nth-of-type(1) {
    flex: 1 0 100% !important;
    width: 100% !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 8px !important;
  }

  #aiAgent,
  #ragSelect,
  #promptSelect {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    height: 38px !important;
    padding: 0 10px !important;
    font-size: 13px !important;
  }

  #uploadMenu {
    position: fixed !important;
    top: 52px !important;
    right: 10px !important;
    width: min(260px, calc(100vw - 20px)) !important;
  }

  body > nav + div {
    min-height: 0 !important;
    overflow: hidden !important;
  }

  #sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: min(82vw, 320px) !important;
    height: 100dvh !important;
    z-index: 50 !important;
    overflow-y: auto !important;
    transform: translateX(0);
  }
  #sidebar.-translate-x-full { transform: translateX(-100%) !important; }

  #chatArea {
    padding: 12px 12px 8px !important;
  }

  #welcomeMessage > div {
    width: 100% !important;
    max-width: 100% !important;
    padding: 22px 18px !important;
    border-radius: 20px !important;
  }

  #chatArea > .try-message-row {
    max-width: 100% !important;
    margin-bottom: 14px !important;
  }
  .try-user-bubble {
    max-width: 88vw !important;
    padding: 12px 40px 12px 14px !important;
    border-radius: 16px !important;
  }
  .try-assistant-bubble {
    width: 100% !important;
    padding: 6px 36px 6px 0 !important;
  }
  .try-message-bubble,
  .markdown-body {
    font-size: 15px !important;
    line-height: 1.7 !important;
  }

  main + div,
  body > nav + div > div > div:last-child {
    padding: 10px !important;
    background: #fff !important;
  }
  .input-container {
    border-radius: 18px !important;
    box-shadow: 0 8px 28px rgba(0,0,0,.06) !important;
  }
  #messageInput {
    min-height: 78px !important;
    max-height: 34dvh !important;
    padding: 12px !important;
    font-size: 15px !important;
    border-radius: 18px 18px 0 0 !important;
  }
  #messageInput + div {
    padding: 8px 10px !important;
    gap: 8px !important;
  }
  #messageInput + div > div:first-child {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }
  #submitBtn {
    min-width: 68px !important;
    height: 38px !important;
    padding: 0 14px !important;
    border-radius: 999px !important;
  }
}

@media (max-width: 390px) {
  #clearAllChatsBtn,
  body > nav > a[href="admin/index.html"] {
    display: none !important;
  }
  body > nav > div:nth-of-type(1) {
    grid-template-columns: 1fr !important;
  }
}
