:root {
  --primary-bg: #1E1E1E;
  --secondary-bg: #2D2D2D;
  --accent-color: #0D8BF0;
  --text-color: #FFF;
  --secondary-text: #B0B0B0;
  --border-radius: 1.2rem;
  --transition: all 0.3s ease;
  --scroll-color: #424242;
  --btn-bg: rgba(255, 255, 255, 0.1);
  --btn-hover: rgba(255, 255, 255, 0.2);
  --bord: 1px solid var(--btn-bg);
  --header-color: #1E1E1E;
  --scroll-width: 8px;
  --scroll-radius: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-color) var(--primary-bg);
}

/* Scrollbar style for WebKit (Chrome, Edge) */
::-webkit-scrollbar { width: var(--scroll-width); }
::-webkit-scrollbar-track {
  background: var(--primary-bg);
  border-radius: var(--scroll-radius);
}
::-webkit-scrollbar-thumb {
  background: var(--scroll-color);
  border-radius: var(--scroll-radius);
}
::-webkit-scrollbar-thumb:hover {
  background: #333;
}
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  background-color: var(--primary-bg);
  color: var(--text-color);
  overflow: hidden;
}

a { color: #008CBA; }

/*==========================*/
/*         sidebar          */
/*==========================*/
.sidebar {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: -300px;
  width: 300px;
  height: 100%;
  background: #222;
  color: white;
  transition: left 0.3s;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
  padding: 0;
  z-index: 1;
}

.section-label {
  margin-top: 1em;
  margin-bottom: 0.5em;
  padding: 4px 8px;
  background-color: #909090;
  color: #222;
  font-size: 0.85em;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
}

.sidebar.open { left: 0; }

.sidebar-content {
  width: 100%;
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-content li {
  padding: 10px;
  margin: 0;
  position: relative;
}

.sidebar-content li a {
  color: white;
  text-decoration: none;
  display: inline-block;
  width: calc(100% - 30px);
}

.sidebar-content li:hover {
  background: rgba(255, 255, 255, 0.2);
  z-index: 1;
  cursor: pointer;
  border-radius: 0.5rem;
}

.sidebar-content li .menu-button {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  cursor: pointer;
  color: silver;
}

.sidebar-content li:hover .menu-button {
  display: block;
}

.sidebar-content li:hover .menu-button:hover {
  color: white;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: #333;
}

.close-sidebar {
  position: absolute;
  right: 10px;
  color: white;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

.hamburger-button {
  background-color: var(--btn-bg);
  color: var(--text-color);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  padding: 0.7rem 1.5rem;
  font-size: 1rem;
  border-radius: var(--border-radius);
}

.context-menu {
  position: absolute;
  background-color: #333;
  color: white;
  list-style: none;
  padding: 0;
  margin: 0;
  border-radius: 5px;
  box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.3);
  z-index: 999;
  min-width: 150px;
}

.context-menu li {
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 5px;
  padding-left: 15px;
  margin-left: 0;
}

.context-menu li:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/*==========================*/
/* page & scrollbar styling */
/*==========================*/
.page_container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  height: calc(100vh - 70px);
  display: flex;
  flex-direction: column;
  overflow: auto;
}

/*==========================*/
/* Common components styles */
/*==========================*/
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background: #222;
}

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

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.model-selector { min-width: 200px; }

.model-selector option {
  background-color: #333;
  color: white;
}

/* Layout */
.app-controls { display: flex; gap: 0.8rem; align-items: center; }

/*==========================*/
/*    Responsive Design     */
/*==========================*/
@media (max-width: 768px) {
  .header { padding: 0.8rem 1rem; }
  .header h1 { font-size: 1.2rem; }
  .model-selector { min-width: 120px; }
  .page_container { padding: 0.5rem; }
  .message { max-width: 95%; }
  .settings_content { width: 95%; }
}

/*==========================*/
/*     buttons styling      */
/*==========================*/
.btn, .model-selector, .query-button, .copy-button, .edit-button, .raw-button, .delete-button, .copy-code-button {
  background-color: var(--btn-bg);
  color: var(--text-color);
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn, .model-selector {
  padding: 0.7rem 1.5rem;
  font-size: 1rem;
  border-radius: var(--border-radius);
}

.btn:hover, .model-selector:hover, .query-button:hover, .copy-code-button:hover { background-color: var(--btn-hover); }

.btn-primary {
  background-color: var(--accent-color);
  color: white;
}

.btn-primary:hover, .send-button:hover { background-color: #0A6BC0; }

/*==========================*/
/*     messages styling     */
/*==========================*/
.chat-container {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 1.5rem;
  padding: 1rem;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.message {
  display: flex;
  max-width: 85%;
}

.message.user { align-self: flex-end; }
.message.assistant { align-self: flex-start; }

.avatar {
  width: 48px;
  height: 48px;
  font-size: 1.4rem;
  border-radius: 50%;
  margin-right: 0.8rem;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}

.user .avatar {
  background-color: #2196F3;
  margin-right: 0;
  margin-left: 0.8rem;
  order: 1;
}

.system .avatar { background-color: #37474F; }
.assistant .avatar { background-color: #FFF; }

.message-content {
  padding: 1rem;
  border-radius: var(--border-radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user .message-content {
  background-color: var(--accent-color);
  border-radius: 1.2rem 1.2rem 0 1.2rem;
}

.system .message-content,
.assistant .message-content {
  background-color: var(--secondary-bg);
  border-radius: 1.2rem 1.2rem 1.2rem 0;
}

.msg_container {
  display: flex;
  flex-direction: column;
}

/*==========================*/
/*     Typing animation     */
/*==========================*/
.typing-indicator {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  margin: 0 3px;
  animation: typing-dot 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/*==========================*/
/*     messages toolbar     */
/*==========================*/
.message-footer {
  transition: opacity 0.2s ease-out;
  margin: 0.4rem;
  opacity: 0;
}

.message.assistant:hover .message-footer,
.message.user:hover .message-footer { opacity: 1; }

.copy-button, .edit-button, .raw-button, .delete-button {
  background-color: var(--primary-bg);
  color: var(--secondary-text);
  border-radius: 4px;
  width: 28px;
  height: 28px;
  font-size: 1.0em;
}

.copy-button:hover, .raw-button:hover, .edit-button:hover, .delete-button:hover { background-color: var(--secondary-bg); }

/*==========================*/
/*     Chat input area      */
/*==========================*/
.chat-input-container {
  position: relative;
  background-color: var(--secondary-bg);
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
}

.chat-input {
  width: 100%;
  padding: 1rem 3.5rem 1rem 1rem;
  background-color: transparent;
  border: none;
  color: var(--text-color);
  font-size: 1rem;
  resize: none;
  border-radius: var(--border-radius);
  min-height: 60px;
}

.chat-input:focus { outline: none; }

.send-button, .stop-button {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0;
}

.send-button {
  background-color: var(--accent-color);
  display: flex;
}

.stop-button {
  background-color: #e74c3c;
  display: none;
  padding-bottom: 4px;
}

.stop-button:hover { background-color: #c0392b; }

.generating .stop-button { display: flex; }
.generating .send-button { display: none; }

.sample-queries {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: center;
}

.query-button {
  color: var(--secondary-text);
  padding: 0.8rem 1.2rem;
  font-size: 0.9rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 200px;
  border-radius: var(--border-radius);
}

.query-button:hover { color: var(--text-color); }

/*==========================*/
/*         Settings         */
/*==========================*/
.settings {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.settings.visible {
  opacity: 1;
  visibility: visible;
}

.settings_content {
  background-color: var(--secondary-bg);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.settings_header, .settings_footer {
  display: flex;
  padding: 1rem;
}

.settings_header {
  justify-content: space-between;
  align-items: center;
  border-bottom: var(--bord);
}

.settings_footer {
  border-top: var(--bord);
  justify-content: flex-end;
  gap: 0.8rem;
}

.settings_title {
  font-size: 1.2rem;
  font-weight: 600;
}

.close_settings, .close-sidebar {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 1.5rem;
  cursor: pointer;
}

.settings_body { 
  padding: 1.5rem; 
  flex: 1;
  overflow-y: auto;
  max-height: calc(80vh - 6rem);
}

.form-group { margin-bottom: 1.5rem; }

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 0.8rem;
  background-color: rgba(0, 0, 0, 0.2);
  border: var(--bord);
  border-radius: 0.5rem;
  color: var(--text-color);
  font-size: 1rem;
  resize: vertical;
}

.custom-param-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.custom-param-row .form-control:first-child { flex: 2; }
.custom-param-row .form-control:nth-child(2) { flex: 1; }

.form-control:focus {
  outline: none;
  border-color: var(--accent-color);
}

/*==========================*/
/*         Markdow          */
/*==========================*/
ul, ol {
  padding: 0.5em 1.5em;
  margin-left : 1em;
}

ul { list-style-type: disc; }

li {
  margin-left : 1em;
  padding-left : 0.5em;
}

/*==========================*/
/*       Code Header        */
/*==========================*/
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5em 1em;
  background-color: var(--header-color);
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  border: 1px solid #3A3A3A;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  margin-top: 1em;
}

.code-language { /* language name */
  font-size: .75rem;
  font-family: ui-sans-serif, -apple-system, system-ui, Segoe UI, Helvetica, Apple Color Emoji, Arial, sans-serif, Segoe UI Emoji, Segoe UI Symbol;
  color: #b4b4b4;
}

.copy-code-button {
  background-color: var(--header-color);
  font-size: .75rem;
  font-family: ui-sans-serif, -apple-system, system-ui, Segoe UI, Helvetica, Apple Color Emoji, Arial, sans-serif, Segoe UI Emoji, Segoe UI Symbol;
  color: #b4b4b4;
  border: none;
}

.copy-code-button .icon {
  display: inline-block;
  width: 14px;
  height: 14px;
}

pre[class*=language-] {
  background: #282C34;
  margin-top: 0;
}

/*==========================*/
/*     Thinking section     */
/*==========================*/
.thinking-content {
  color: #777;
  font-size: 0.85em;
  border-left: 2px solid #777;
  padding-left: 10px;
  margin: 10px 0;
  cursor: pointer;
  display: inline-block;
  transition: all 0.3s ease;
}

.hidden { display: none; }

.thinking-tag {
  background: #494949;
  border-radius: 10px;
  justify-content: center;
  align-items: center;
  width: fit-content;
  padding: 4px 10px;
  display: flex;
  cursor: pointer;
}

/* blockquote */
blockquote {
  font-style: italic;
  display: block;
  margin: 1em;
  padding: 1em;
  background: #d6d6d6;
  color: black
}

blockquote:before {
  content: '“';
  color: #999;
  font-family: "Georgia", cursive;
  font-size: 4em;
  line-height: 0.1em;
  margin-right: 0.25em;
  vertical-align: -0.4em;
  display: inline-block;
}

/*==========================*/
/*          LaTeX           */
/*==========================*/
.math_white_bg {
  background-color: white;
  color: black;
  padding: 0.7em 1em;
}

.math_inline {

}

/* boxed result */
.boxed {
  display: inline-block;
  border: 2px solid #0077B7;
  border-radius: 10px;
  padding: 2px 6px;
}

.mbox { font-style: normal; }

/* table (must be in the latest CSS properties )*/
table, th, td {
  border: 1px solid;
  border-collapse: collapse;
  padding: 10px;
  border: var(--bord);
}

table {
  margin-bottom: 1em;
  background: #767676;
}

th { font-weight: bold; }
