@supports (-webkit-touch-callout: none) {
  body {
    touch-action: none;
  }
}

html, body {
  touch-action: manipulation; /* Prevents double-tap zoom */
  overflow-x: hidden; /* Prevents unwanted horizontal scrolls */
}

.spg-container {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    height: calc(100dvh - var(--header-height)) !important;
    display: flex;
    flex-direction: column;
    background: var(--black);
    overflow: hidden;
    padding-right: var(--gap-2xs);
    padding-left: var(--gap-2xs);
    padding-bottom: var(--gap-2xs);
}

/* Chatbox takes 80% of the screen */
#spg-chatbox {
    flex-grow: 1;
    overflow-y: auto;
    padding: var(--gap-2xs);
    background-color: var(--black-l-1);
    border: var(--btn-border) solid var(--black-l-3);
    border-radius: var(--btn-border-radius);
    display: flex;
    flex-direction: column;
    gap: var(--gap-m);
    margin-bottom: var(--gap-2xs);
}

/* Messages */
.spg-message {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: var(--btn-border-radius);
    margin-bottom: 8px;
    word-wrap: break-word;
    display: inline-block;
    position: relative;
    color: var(--white);
    background-color: var(--black);
}

/* Ensure correct background colors */
.spg-user {
    align-self: flex-end;
    text-align: right;
}

.spg-bot {
    align-self: flex-start;
    text-align: left;
}

/* Copy Button */
.spg-bot:hover .spg-copy-btn {
    opacity: 1;
    visibility: visible;
}

/* Copy Button - Fixed Width & Visibility Fix */
.spg-copy-btn {
    position: absolute;
    bottom: -30px;
    right: 2px;
    padding: 5px;
    background: var(--black-l-1) !important;
    border: none;
    cursor: pointer;
    border-radius: var(--btn-border-radius);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    color: var(--white);
    width: 75px; /* Fixed width to prevent resizing */
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
	font-size:12px;
	z-index:500;
}

/* Prevent flickering when clicked */
.spg-copy-btn.clicked {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Ensure text transition smooth */
.spg-copy-btn span {
    display: block;
    width: 100%;
    text-align: center;
}

/* Button hover effect */
.spg-copy-btn:hover {
    background: var(--black-1-1);
}

/* Input Container - Fixed at bottom */
.spg-input-container {
    display: flex;
    align-items: center;
    background: var(--black-l-1);
    border-top: 1px solid var(--black-l-1);
    position: fixed;
    bottom: 0;
    width: 100%;
    height: auto;
    min-height: 50px;
    padding: var(--gap-s);
}

/* Input Box */
#spg-user-input {
    flex-grow: 1;
    padding: 8px;
    border: var(--btn-border) solid var(--btn-border-primary-default);
    border-radius: var(--btn-border-radius);
    resize: none;
    background: var(--black-l-2);
    color: var(--white);
    height: 36px; /* Compact height */
    max-height: 36px; /* Prevents it from expanding */
    margin-bottom: var(--gap-3xs);
    overflow-y: hidden;
}

#spg-user-input::placeholder {
    color: var(--black-l-4); /* Change this to your desired colour */
    opacity: 1; /* Ensures full opacity */
}

/* For older versions of Firefox */
#spg-user-input:-moz-placeholder {
    color: var(--black-l-4);
    opacity: 1;
}

/* For older versions of Internet Explorer */
#spg-user-input:-ms-input-placeholder {
    color: var(--black-l-4);
}


/* Send Button */
#spg-send-btn {
    margin-top: 4px;
    padding: 8px 12px;
    background: var(--btn-bg-primary-default);
    border: var(--btn-border) solid var(--btn-border-primary-default);
    cursor: pointer;
    border-radius: var(--btn-border-radius);
    transition: background 0.3s ease-in-out, border 0.3s ease-in-out;
    color: var(--black);
    text-align: center;
    height: 36px; /* Matches input box height */
    margin-bottom: var(--gap-3xs);
}

#spg-send-btn:hover {
    background: var(--btn-bg-primary-hover);
    border-color: var(--btn-border-primary-hover);
}

/* Bot Typing Indicator */
.spg-typing {
    background-color: var(--black-1-1);
    align-self: flex-start;
    text-align: left;
    padding: 8px 12px;
    border-radius: var(--btn-border-radius);
    display: flex;
    align-items: center;
    width: auto;
    max-width: 200px;
    justify-content: center;
    gap: 5px;
}

/* Hermes is typing text */
.spg-typing-text {
    font-size: 14px;
    color: var(--white);
}

/* Animated Dots */
.spg-typing-dots span {
    display: inline-block;
    font-size: 20px;
    font-weight: bold;
    color: var(--white);
    animation: spg-blink 1.5s infinite;
}

.spg-typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.spg-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.spg-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Blinking Effect */
@keyframes spg-blink {
    0% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* Mobile Fixes */
@media (max-width: 768px) {
    .spg-container {
        height: calc(100vh - var(--header-height));
    }

    #spg-chatbox {
        height: calc(100vh - var(--header-height) - 50px);
    }

    .spg-input-container {
        height: 50px;
    }

    #spg-user-input,
    #spg-send-btn {
        height: 36px;
        max-height: 36px;
    }
}
