@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;600&display=swap');

/* Light Mode Variables */
:root {
  --color-bg: #ffffff; /* White */
  --color-primary-text: #23272a; /* Not quite black */
  --color-secondary-text: #2c2f33; /* Dark, but not black */
  --color-tertiary-text: #99aab5; /* Greyple */
  --color-border: #99aab5; /* Greyple */
  --color-accent1: #7289da; /* Blurple */
  --color-accent2: #5865f2; /* New Blurple */
  --color-accent3: #99aab5; /* Greyple for timestamps */
  --color-accent4: #57f287; /* Green */
  --color-accent5: #ed4245; /* Red */
}

/* Dark Mode Variables */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #23272a; /* Not quite black */
    --color-primary-text: #ffffff; /* White */
    --color-secondary-text: #99aab5; /* Greyple */
    --color-tertiary-text: #b9bbbe; /* Lighter Greyple (Discord's text color on dark bg) */
    --color-border: #2c2f33; /* Dark, but not black */
    --color-accent1: #7289da; /* Blurple */
    --color-accent2: #5865f2; /* New Blurple */
    --color-accent3: #99aab5; /* Greyple for timestamps */
    --color-accent4: #57f287; /* Green */
    --color-accent5: #ed4245; /* Red */
  }
}

/* CSS Reset */
*,
*::before,
*::after {
  box-sizing: border-box; /* Ensure padding does not affect the total width or height */
  margin: 0; /* Remove default margin */
  padding: 0; /* Remove default padding */
}

/* Scrollbar styling */
html {
  scroll-behavior: smooth; /* Enables smooth scrolling for anchor links */
  height: 100%; /* Fixes the full height for the html element */
}

body {
  margin: 0;
  font-family: JetBrains Mono, Arial, Helvetica, sans-serif;
  font-weight: 300;
  background-color: var(--color-bg);
  color: var(--color-primary-text);
  line-height: 1.2; /* Improves readability */
  min-height: 100%; /* Ensures at least full viewport height */
  overflow-x: hidden; /* Hides horizontal scrollbar if not needed */
}

a {
  cursor: pointer;
}

#search-bar {
  width: 100%;
  height: 3em;  /* TODO: Turn into constant */
  display: flex;
  justify-content: right;
  align-items: center;
  padding-right: 1em;
}

#search-bar > input {
  padding: 0.5em;
  border: 2px solid var(--color-accent5);
  border-radius: 0.5em;
  background-color: var(--color-bg);
  color: var(--color-primary-text);
  transition: all 0.2s ease;
}

#search-bar > input:focus {
  border-color: var(--color-accent1);
  outline: none;
  box-shadow: 0 0 0 2px var(--color-accent5);
}

/* Structure and layout */
#channels {
  float: left;
  width: 25%; /* Channel takes 25% of the view width */
  box-sizing: border-box; /* Include padding and borders in the width */
  padding: 1em; /* Spacing inside the channels */
  height: calc(100vh - 3em); /* Full height */
  overflow-y: auto; /* Enable scrolling for overflow content */
}

#content {
  margin-left: 25%; /* Content starts after the channels div */
  padding: 1em; /* Spacing inside the content */
  height: calc(100vh - 3em); /* Full height */
  overflow-y: auto; /* Enable scrolling for overflow content */
}

/* Style the list elements */
ul {
  list-style: none;
  padding: 0;
}

ul li {
  margin: 0.5em 0;
}

/* Style the headings */
h2 {
  margin-top: 0;
}

/* Responsive design */
@media (max-width: 768px) {
  #channels,
  #content {
    float: none;
    width: auto;
    margin-left: 0;
    height: auto;
  }
}

/* Dark theme media query */
@media (prefers-color-scheme: dark) {
  body {
    background-color: var(--color-bg);
    color: var(--color-primary-text);
  }

  #channels {
    border-right: 1px solid var(--color-border);
  }
}

#channels h2 {
  color: var(--color-accent5);
  border-bottom: 2px solid var(--color-accent1);
  padding-bottom: 0.3em;
  margin-bottom: 0.5em;
}

#channels a {
  display: block;
  color: var(--color-primary-text);
  text-decoration: none;
  padding: 0.3em 0.5em;
  border-radius: 0.3em;
  transition: all 0.2s ease;
}

#channels a:hover {
  background-color: var(--color-accent5);
  color: var(--color-bg);
  transform: translateX(0.2em);
}

#channels a.active {
  background-color: var(--color-accent5);
  color: var(--color-bg);
  transform: translateX(0.2em);
}

#content ul li img.e {
  height: 1.2em;
  vertical-align: sub;
}

span.usr {
  font-weight: 600;
  color: var(--color-accent5);
  margin-right: 0.5em;
}

span.time {
  font-size: 0.7em;
  color: var(--color-accent3);
  position: relative;
}

span.avatar {
  width: 40px;
  height: 40px;
  text-align: center;
  position: absolute;
  left: 0;
  overflow: hidden;
  padding-top: 2px;
}

span.avatar img {
  border-radius: 9999px;
  height: 100%;
}

#content ul li {
  padding-left: 52px;
  position: relative;
}

#loading-indicator {
  display: none; /* Hidden by default */
}

.htmx-request #loading-indicator {
  display: block; /* Shown when an HTMX request is in progress */
}

.jump-btn {
  cursor: pointer;
  background-color: var(--color-accent5);
  border: none;
  border-radius: 0.5em;
  padding: 0.2em 0.5em;
  font-size: 75%;
  color: var(--color-bg);
  display: none;
  transition: all 0.2s ease;
}

.jump-btn:hover {
  background-color: var(--color-accent1);
  transform: scale(1.05);
}

.clickable {
  cursor: pointer;
}

li.username:hover .jump-btn {
  display: inline;
}

.scroller {
  height: 64px;
}

.scroller.htmx-settling {
  display: none;
}

/* Add new styles for special elements */
.highlight {
  color: var(--color-accent5);
}

/* Update message styles */
.messages-container {
  margin-bottom: 1em;
  border-left: 1px solid var(--color-accent3);
  padding-left: 0.5em;
  transition: border-color 0.2s ease;
}

.messages-container:hover {
  border-left-color: var(--color-accent5);
  background-color: color-mix(in srgb, var(--color-accent5) 10%, var(--color-bg));
}

/* Update message content style */
.msg {
  color: var(--color-primary-text);
  margin-left: 0.5em;
}

.copy-link-btn {
  background: none;
  border: none;
  color: var(--color-accent5);
  cursor: pointer;
  font-size: 0.8em;
  margin-left: 8px;
  border-radius: 3px;
  display: none;
  transition: all 0.2s ease;
}

.copy-link-btn:hover {
  background-color: color-mix(in srgb, var(--color-accent5) 10%, var(--color-bg));
}

li.username:hover .copy-link-btn {
  display: inline;
}

#target-message {
  border-left: 3px solid var(--color-accent5);
  background-color: color-mix(in srgb, var(--color-accent5) 15%, var(--color-bg));
  animation: highlight-fade 2s ease-out;
}

@keyframes highlight-fade {
  0% {
    background-color: color-mix(in srgb, var(--color-accent5) 30%, var(--color-bg));
  }
  100% {
    background-color: color-mix(in srgb, var(--color-accent5) 15%, var(--color-bg));
  }
}

/* Style for the active navigation link in the channel list */
nav ul li a.active {
  background-color: #4A5568; /* A pleasant dark gray - adjust to your theme */
  color: white; /* Ensure text is readable on the new background */
  font-weight: bold;
  border-radius: 4px; /* Optional: for rounded corners */
  padding: 0.5em 0.75em; /* Optional: adjust padding if needed */
  display: block; /* Optional: makes the whole area clickable and better for padding */
}

/* Adjustments for consistent spacing if you use display:block and padding */
nav ul li a {
  padding: 0.5em 0.75em; /* Ensure non-active links have same padding for alignment */
  display: block; /* Ensure non-active links behave similarly */
  text-decoration: none; /* Common practice to remove underline from nav links */
  color: inherit; /* Inherit color from parent, or set a specific one */
  border-radius: 4px; /* Match active link's border-radius */
}

nav ul {
  list-style-type: none; /* Remove default list bullets */
  padding-left: 0; /* Remove default padding */
}

nav ul li {
  margin-bottom: 2px; /* Add a little space between channel items */
}

/* Optional: Hover effect for non-active channels */
nav ul li a:not(.active):hover {
  background-color: #e2e8f0; /* A light gray for hover */
  color: #2d3748; /* Darker text on hover */
}
