:root {
  --bg-dark: #070f45;
  --text-dark: #e8e6e3;
  --bg-light: #f0f0f0;
  --text-light: #111;
  --sidebar-bg-dark: #030622;
  --history-bg-dark: #070f45;

  /* for important buttons, like new chat */
  --btn-primary-dark: #230084;
  --btn-primary-hover-dark: #4614b5;

  /* for less important buttons, like history, or support */
  --btn-secondary-dark: #aaa;
  --btn-secondary-hover-dark: #3614b5;
  --accent-orange: #f3923a;

  /* for the new chat selection buttons */
  --btn-chat-dark: #7b00d4;
  --btn-chat-hover-dark: #4614b5;
  --btn-chat-active: #4614b5;
}

body {
  padding: 0;
  margin: 0;
  font-family: "Reem Kufi", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif;
  height: 100vh;
}

body:not(.light-mode) {
  background-color: var(--bg-dark);
  color: var(--text-dark);
}

html.light-mode,
body.light-mode {
  background-color: var(--bg-light);
  color: var(--text-light);
}

#sidebar {
  position: fixed;
  left: -200px;
  top: 0;
  width: 200px;
  height: 100vh;
  background-color: var(--sidebar-bg-dark);
  color: var(--text-dark);
  padding: 2% 10px;
  box-sizing: border-box;
  overflow: visible;
  transition: left 0.3s ease;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

#sidebar h2 {
  margin-top: 0;
}

#sidebar ul {
  list-style: none;
  padding: 0;
}

#sidebar li {
  margin-bottom: 10px;
}

#sidebar a {
  color: var(--text-dark);
  text-decoration: none;
}

#sidebar a:hover {
  text-decoration: underline;
}

#history-section {
  margin: 0 0 15px;
  padding: 10px;
  background: var(--history-bg-dark);
  border-radius: 5px;
  padding-bottom: 15px;
}

#history-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

#history-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#history-list .history-item {
  padding: 6px 10px;
  margin-bottom: 5px;
  border: 1px solid var(--btn-secondary-dark);
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

#history-list .history-item.deleting {
  animation: shrink 0.3s ease-out forwards;
}

@keyframes shrink {
  to {
    opacity: 0;
    transform: scaleY(0);
    transform-origin: top;
  }
}

#history-list .history-item:hover,
#history-list .history-item.selected {
  background: var(--btn-secondary-hover-dark);
}

#history-list .history-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
}

#history-list .history-delete-btn img {
  filter: grayscale(100%);
  transition: filter 0.2s ease;
}

#history-list .history-delete-btn:hover img {
  filter: grayscale(0%) sepia(100%) hue-rotate(-50deg) saturate(400%);
}

.logoutBtn {
  margin-top: 20px;
  padding: 10px 15px;
  background: rgb(0 0 0 / 0%);
  border: 2px solid var(--btn-secondary-dark);
  border-radius: .5rem;
  color: var(--text-dark);
  cursor: pointer;
  width: 100%;
  text-decoration: none;
  font-family: inherit;
}

#logoutBtn:hover,
.logoutBtn:hover {
  background: var(--btn-secondary-hover-dark);
}

.pulse {
  animation: pulse-orange 2s ease-in-out infinite;
}

#main-content {
  padding: 20px 5%;
  max-width: 800px;
  margin: 0 auto;
  height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

@media (width <=767px) {
  #main-content {
    padding-top: 50px;
  }
}

#menuToggle {
  display: none;
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1000;
  background: #333;
  color: var(--text-dark);
  border: none;
  padding: 10px;
  cursor: pointer;
  border-radius: 5px;
}

#menuToggle span {
  display: block;
  width: 25px;
  height: 3px;
  margin: 5px;
  background: var(--text-dark);
  transition: all 0.3s ease;
}

@media (width >=768px) {
  #sidebar {
    left: 0;
  }

  #menuToggle {
    display: none;
  }

  .centre {
    margin-left: 230px;
  }
}

@media (width <=767px) {
  #sidebar {
    left: -200px;
  }

  #menuToggle {
    display: block;
  }

  #sidebar.active {
    left: 0 !important;
  }

  #sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgb(0 0 0 / 50%);
    z-index: 999;
  }

  body.sidebar-open #sidebar-overlay {
    display: block;
  }

  #menuToggle.hidden {
    display: none;
  }

  #main-content {
    margin-left: 0;
    max-width: 100vw;
  }
}

#sidebar .logout-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

#sidebar #logoutBtn {
  margin-top: auto;
}

#sidebar .sidebar-setting {
  padding: 10px;
  border-top: 1px solid #444;
  margin-top: 10px;
}

#sidebar .sidebar-setting label {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
}

#sidebar .sidebar-setting input[type="number"] {
  width: 100%;
  padding: 5px;
  border-radius: 4px;
  border: 1px solid #555;
  background: #222;
  color: var(--text-dark);
}

#sidebar .sidebar-setting input[type="number"].invalid {
  border-color: #ff6b6b;
  background: #2a1a1a;
}

#sidebar .sidebar-setting .input-error {
  color: #ff6b6b;
  font-size: 12px;
  margin-top: 3px;
}

#log,
#history-chat {
  overflow-y: auto;
  width: 100%;
  flex: 1 1 auto;
  font-family: sans-serif;
  text-align: left;
}

#log.visible {
  display: block;
}

#log:not(.visible) {
  display: none;
}


#history-chat.visible {
  display: block;
}

#history-chat:not(.visible) {
  display: none;
}

html.light-mode #log {
  color: var(--text-light);
}

html.light-mode #history-chat {
  background: var(--history-bg-light);
  color: var(--text-light);
}

#showActiveChatBtn {
  margin: 0 0 10px;
  padding: 10px 15px;
  background: var(--btn-primary-dark);
  color: var(--text-dark);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  width: 100%;
}

#showActiveChatBtn:hover {
  background: var(--btn-secondary-hover-dark);
}

.mode-description {
  margin: 10px 0;
  font-style: italic;
  color: #aaa;
}

@keyframes pulse-orange {
  50% {
    background: #d4a017;
  }
}

.user_msg_provisional {
  color: #aaa;
}

html.light-mode .user_msg_provisional {
  color: #666;
}

.user_msg {
  padding: 16px 0;
}

pre {
  white-space: pre-wrap;
  font-family: "Courier New", Courier, monospace;
}

pre:has(code) {
  background-color: #111;
  padding: 4px 10px;
  border-radius: 5px;
  color: #eee;
}


#modeDiv .mode-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

#modeDiv .mode-btn {
  border: 2px solid var(--btn-chat-dark);
  background: var(--btn-chat-dark);
  color: var(--text-dark);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s;
  flex: 1 1 auto;
}

#modeDiv .mode-btn:hover {
  background: var(--btn-chat-hover-dark);
}

#modeDiv .mode-btn.active {
  background: var(--btn-chat-active);
  font-weight: bold;
  border: 2px solid var(--btn-secondary-dark);
}

html.light-mode #modeDiv .mode-btn.active {
  border: 2px solid var(--text-light);
}

#main-content .startButton {
  border: 0;
  background: var(--btn-chat-dark);
  color: var(--text-dark);
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  font-weight: bold;
  font-size: 14px;
  margin: 3px;
}

#language {
  border: 1px solid white;
  background: var(--history-bg-dark);
  color: var(--text-dark);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  margin-top: 10px;
  width: 120px;
}

html.light-mode #language {
  background: var(--bg-light);
  color: var(--text-light);
  border-color: black;
}


#main-content .startButton:hover {
  background: var(--btn-chat-hover-dark);
}

#main-content>h1,
#main-content>#modeDiv,
#main-content>div:has(.startButton),
#main-content>#refreshNotice {
  text-align: center;
  width: 100%;
}

.usage-div {
  font-size: 12px;
  color: #888;
  margin-top: 10px;
}

.error-div {
  margin: 10px 0;
  padding: 15px;
  background: #fee;
  border: 2px solid #f00;
  border-radius: 5px;
  color: #c00;
  font-family: "Courier New", Courier, monospace;
}

html.light-mode .error-div {
  background: #fee;
  color: #c00;
  border-color: #f00;
}


.robot_msg {
  margin: 10px 0;
}

.robot_prefix {
  font-weight: bold;
  color: #6b5;
}

hr {
  border: 0;
  height: 1px;
  background: var(--btn-secondary-dark);
  margin: 15px 0;
}

html.light-mode #main-content hr {
  background: #ccc;
}

#main-content .startButton:active {
  background: #5a5a5a;
}

#stopRecording {
  border: 2px solid var(--btn-secondary-dark);
  background: var(--history-bg-dark);
  color: var(--text-dark);
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  margin: 5px;
  transition: all 0.2s;
}

#stopRecording:hover {
  background: var(--sidebar-bg-dark);
}

.local-output {
  margin: 10px 0;
  white-space: pre-wrap;
}

.local-output pre {
  margin: 0;
  padding: 0;
}

.local-output code {
  color: #eee;
}

.tooltip-icon {
  cursor: help;
  font-style: normal;
  position: relative;
}

.tooltip-icon::after {
  margin-left: 8px;
  content: attr(data-tooltip);
  position: absolute;
  padding: 8px 12px;
  background: #222;
  color: var(--text-dark);
  border-radius: 4px;
  font-size: 12px;
  min-width: 160px;
  white-space: pre-line;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
  z-index: 2000;
}

.tooltip-icon:hover::after {
  opacity: 1;
}

#login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgb(0 0 0 / 70%);
  z-index: 2000;
  display: none;
  justify-content: center;
  align-items: center;
}

#login-overlay:not([hidden]) {
  display: flex;
}

#login-modal {
  background: #333;
  color: var(--text-dark);
  padding: 30px;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  text-align: center;
}

#login-modal h2 {
  margin-top: 0;
}

#login-modal iframe {
  width: 100%;
  min-height: 270px;
  border: none;
  border-radius: 4px;
}

html.light-mode #login-overlay {
  background: rgb(0 0 0 / 40%);
}

html.light-mode #login-modal {
  background: #f0f0f0;
  color: #111;
}

.newChatBtn {
  border: none;
  background-color: var(--btn-primary-dark);
  font-size: large;
  font-weight: bold;
}

.newChatBtn:hover {
  background-color: var(--btn-primary-hover-dark);
}

.warning-div {
  margin: 10px 0;
  padding: 15px;
  background: #fff3cd;
  border: 2px solid #ffc107;
  border-radius: 5px;
  color: #856404;
  font-family: "Courier New", Courier, monospace;
}

.center {
  display: flex;
  justify-content: center;
  align-items: center;
}

@font-face {
  font-display: swap;
  font-family: "Reem Kufi";
  font-style: normal;
  font-weight: 400;
  src: url("/reem-kufi-v28-latin-regular.20aef0.woff2") format("woff2")
}

@font-face {
  font-display: swap;
  font-family: "Reem Kufi";
  font-style: normal;
  font-weight: 500;
  src: url("/reem-kufi-v28-latin-500.a35370.woff2") format("woff2")
}

@font-face {
  font-display: swap;
  font-family: "Reem Kufi";
  font-style: normal;
  font-weight: 700;
  src: url("/reem-kufi-v28-latin-700.60a748.woff2") format("woff2")
}