.chatbox {
	position: fixed;
	top: calc(var(--header-size) + 0.15rem);
	height: calc(calc(var(--vh) * 100) - var(--header-size) - 0.15rem);
	width: 30rem;
	right: -30rem;
	transition: right 0.5s;
	z-index: 99;

	background: black;
	color: white;
	border-left: 0.1rem solid #333;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.chatbox.active {
	right: 0;
}

.chatbox .toggle {
	position: absolute;
	bottom: 0.5rem;
	left: -2rem;
	width: 2rem;
	height: 3rem;

	appearance: none;
	background: black;
	border: 0.1rem solid #333;
	border-right: none;
	border-radius: 0.5rem 0 0 0.5rem;

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

.chatbox .toggle i {
	font-size: 1rem;
}

.chatbox .toggle img {
	width: 1.5rem;
}

.chatbox .chatbox-header {
    flex: 0;
    position: relative;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    background: var(--color-primary);
    margin-left: -1px;
    border-right: 1px solid var(--color-primary);
}

.chatbox .chatbox-header img {
    background: black;
    padding: .5rem;
    height: 4rem;
    border-top-right-radius: 0.5rem;
}

.chatbox .chatbox-header img+div {
    width: .5rem;
    background: black;
    height: 100%;
    position: relative;
}

.chatbox .chatbox-header img+div::after {
    position: absolute;
    content: " ";
    width: 100%;
    height: 100%;
    background-color: var(--color-primary);
    border-bottom-left-radius: 0.5rem;
}

.chatbox .msg-container {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	padding: 0.5rem;
}

.chatbox .msg-container .msg {
	font-size: .9rem;
	padding: 0.5rem;
	margin-right: 0.5rem;
	align-self: start;
	background: var(--color-primary-hold);
	color: white;
	border-radius: 0.5rem;

    border-bottom-left-radius: 0;
}

.chatbox .msg-container .msg.sent {
	margin-right: 0;
	margin-left: 0.5rem;
	align-self: end;
	background: var(--color-quaternary-hold);

    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0;
}

.chatbox .msg-container img {
    max-width: 100%;
    max-height: 50vh;
}

.chatbox .msg-container a {
    color: white !important;
    tex-decoration: none !important;
}

.chatbox .msg hr {
	border-top: .1rem solid white;
}

.chatbox .msg .title {
	font-size: 1.1rem;
}

.chatbox .msg .subtitle {
	font-size: 1rem;
}

.chatbox .input-container {
	display: flex;
	flex-direction: row;
	gap: 0.5rem;
	align-items: center;
	justify-content: center;
	padding: 0.5rem;
}

.chatbox .input-container textarea {
	flex: 9;
	resize: none;
	padding: 0.3rem 0.2rem;
}

.chatbox .input-container button {
	flex: 1;
	height: 100%;
	appearance: none;
	background: none;
	border: none;
	outline: none;
	margin: 0;
	padding: 0;
}

.chatbox .input-container button svg {
	max-width: 100%;
	max-height: 100%;
	height: 1.5rem;
	fill: var(--color-primary);
}

.chatbox .msg .typing {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: .2rem;
}

.chatbox .msg .typing span {
    width: .5rem;
    height: .5rem;
    background-color: white;
    border-radius: 50%;
    transform-origin: center;
    animation: typingScale 1s infinite;
    opacity: .5;
    scale: .5;
}

.chatbox .msg .typing span:nth-child(2) {
    animation-delay: .2s;
}

.chatbox .msg .typing span:nth-child(3) {
    animation-delay: .4s;
}

@keyframes typingScale {
    from {
        opacity: .5;
        scale: .5;
    }
    50% {
        opacity: 1;
        scale: 1;
    }
    to {
        opacity: .5;
        scale: .5;
    }
}

.chatbox::before {
  content: " ";
  background-color: #0007;

  position: absolute;
  top: 0;
  left: 0;
  z-index: 998;

  width: 100%;
  height: 100%;

  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s;
}

.chatbox::after {
  content: " ";
  border: 0.5rem solid #fff;
  border-left-color: var(--color-primary);
  border-radius: 50%;

  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(0deg);
  z-index: 999;

  width: min(20vw, 5rem);
  height: min(20vw, 5rem);

  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s;

  animation: spinner 1s linear infinite;
}

.chatbox.reconnecting * {
  pointer-events: none;
}

.chatbox.reconnecting::before {
  pointer-events: all;
  opacity: 1;
}

.chatbox.reconnecting::after {
  pointer-events: all;
  opacity: 1;
}
