/* Fonts */
@font-face {
  font-family: "Inter";
  src: url('/static/inter_var.ttf');
}

@font-face {
  font-family: "Inter";
  font-style: italic;
  src: url('/static/inter_ital_var.ttf');
}

@font-face {
  font-family: "Fira Code";
  src: url('/static/fira_code.ttf');
}

@font-face {
  font-family: "Noto Emoji";
  src: url('/static/noto_emoji.ttf');
}

/* Global Styles */
* {
  box-sizing: border-box;
  font-family: "Inter", "Noto Emoji", sans-serif;
  margin: 0;
  padding: 0;
}

:root {
  --bg0: #ffffff;
  --bg1: #e4e9f1;
	--bg2: #dde3ee;
  --t1: #336e80;
  --t2: #5dd9ac;
  --red: #d43a3a;
  --fg2: #3a4d74;
  --fg1: #182030;
	--base-size: clamp(16px, 1.4vw, 32px);
	--max-width: calc(var(--base-size)*36);
	font-size: var(--base-size);
	letter-spacing: 0.02rem;
}

body {
	font-size: 1rem;
	background: var(--bg0);
	color: var(--fg1);
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: 1fr 3fr;
	grid-template-rows: auto 1fr;
	align-content: stretch;
	height: 99vh;
	line-height: 170%;
}

a {
	color: var(--t1);
	cursor: pointer;
}

header {
  grid-area: 1 / 1 / 2 / 2;
  padding: 0.5rem;
  display: grid;
  align-items: center;
  grid-template-columns: 1fr auto auto auto;
  gap: 0.5rem;
}

header a {
  text-decoration: none;
}

header .logo {
  width: 2rem;
  height: 2rem;
}

#sidebar {
  grid-area: 2 / 1 / 3 / 2;
  background: var(--bg0);
  height: 100%;
  align-self: start;
  padding: 0 0.5rem;
  margin: 0.25rem 0;
  display: grid;
  align-content: start;
  gap: 0.25rem;
  overflow-y: auto;
}

#sidebar a {
  text-decoration: none;
  display: block;
  padding: 0.6rem 0.25rem 0.4rem 0.25rem;
  border-top: 1px solid var(--bg2);
  font-size: 83%;
}

main {
  grid-area: 1 / 2 / 3 / 3;
  justify-items: center;
  display: grid;
  padding: 0.5rem;
  height: 100vh;
  overflow-y: scroll;
}

section {
  display: inline-block;
  width: 100%;
  max-width: 120vh;
  margin: 1rem 0;
  padding: 0.5rem;
}

section h1 {
  margin-bottom: 2rem;
}

.btn, button {
  text-decoration: none;
  background: var(--bg2);
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 0.2rem;
  color: var(--t1);
  font-weight: bold;
  cursor: pointer;
  border: 1px solid var(--t1);
  outline: none;
  font-size: inherit;
}

.btn.danger, button.danger {
  color: var(--red);
  border: 1px solid var(--red);
}

.btn:hover, button:hover, .btn:focus, button:focus {
  opacity: 0.8;
}

code {
  font-family: "Fira Code", monospace;
  font-size: 0.8rem;
}

.row-c2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.alert {
  background: var(--bg0);
  padding: 0.5rem;
  border: 1px solid var(--bg2);
}


/* General Forms */
form {
  display: grid;
  gap: 1.5rem;
  background: var(--bg0);
  padding: 1rem 0.5rem;
}

form label {
  display: grid;
  gap: 0.25rem;
}

form small {
  font-size: 0.8rem;
  font-weight: bold;
}

form input {
  border: none;
  outline: none;
  font-family: "Fira Code", monospace;
  border-bottom: 1px solid var(--fg1);
  color: var(--fg1);
  font-size: 0.8rem;
  padding: 0.2rem;
}

form input:focus {
  color: var(--t1);
  border-bottom: 1px solid var(--t1);
}

form button {
  justify-self: start;
}

form progress[value="0"] {
  display: none;
}

form textarea {
  font-size: inherit;
  padding: 0.5rem;
  border: none;
  outline: none;
}

form.htmx-request {
  display: none;
}

form ~ .loader {
  display: none;
  font-size: 1.2rem;
  text-align: center;
  padding: 2rem 0.5rem;
  animation: loadanim 2s ease-in-out infinite;
}

form.htmx-request + .loader {
  display: block;
}

@keyframes loadanim {
  0% {opacity: 1;}
  50% {opacity: 0.3;}
  100% {opacity: 1;}
}



/*
  SCREEN WISE CSS
*/

/* Setup Prompt */

#setup-prompt {
  margin-top: 5rem;
}

/* Manage Sources */

#manage-sources .source-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  padding: 1rem;
  align-items: center;
  gap: 1rem;
  border-top: 1px solid var(--bg2);
}

#manage-sources .source-card form {
  padding: 0;
  display: inline-block;
  background: none;
}

#manage-sources .source-card button {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

#manage-sources .source-card button.inactive {
  filter: grayscale(100%);
} 

#manage-sources .row-c2 {
  margin-top: 1.5rem;
}

#manage-sources .row-c2 form {
  border: 1px solid var(--bg2);
  border-radius: 0.2rem;
}


/* New Conversation */

#new-conversation form {
  border-top: 1px solid var(--bg2);
  margin-top: 1rem;
}


/* Chat Display */

#chat {
  border-radius: 0.2rem;
}

#chat>* {
  margin: 0;
  border-bottom: 1px solid var(--bg2);
  padding: 1.5rem 0.5rem;
}

#chat ul {
  list-style-position: inside;
}

#chat .user-message {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  padding-right: 1rem;
  align-items: start;
}

#chat .user-message .sender {
  color: var(--t1);
  border: 1px solid var(--t1);
  padding: 0.125rem 0.5rem;
  font-size: 70%;
}



#chat .ai-message {
  display: grid;
  gap: 0.25rem;
}

#chat .ai-message .sender {
  color: var(--t1);
  font-size: 70%;
}


#chat .function-call {
  display: grid;
  gap: 0.75rem;
  align-items: center;
}

#chat .function-name b {
  font-size: 75%;
  display: inline-block;
  background: var(--t1);
  padding: 0rem 0.5rem;
  border-radius: 2rem; 
  color: var(--bg0);
  margin-right: 0.5rem;
}

#chat .function-call pre {
  overflow-x: auto;
}

#chat .function-name code {
  color: var(--t1);
  font-weight: 700;
}

#chat .function-call .args {
  padding: 0.5rem;
  background: var(--bg2);
  border-radius: 0.2rem;
  font-family: Fira Code, monospace;
  font-size: 75%;
  line-height: 180%;
}

#chat .function-output {
  overflow-x: auto;
}

#chat table {
  border-collapse: collapse;
  border-radius: 0.25rem;
}

#chat table td, #chat table th {
  border: 1px solid var(--bg2);
  padding: 0.25rem 0.5rem;
  font-family: Fira Code, monospace;
  font-size: 75%;
}

#chat table th {
  background: var(--t1);
  border: 1px solid var(--t1);
  color: var(--bg1);
  font-weight: 700;
}

#chat table tr:nth-child(2n) td {
  background: var(--bg1);
  border: 1px solid var(--bg2);
}

@media print {
  body {height: auto;}
  header {display: none;}
  #sidebar {display: none;}
  main {grid-area: 1 / 1 / 3 / 3; height: auto; overflow-y: none;}
  form {display: none;}
}


