/***********************************************
 * BASE CHATBOX CONTAINER
 ***********************************************/
.chatbox-container {
    position: fixed;
    bottom: 0;
    right: 1rem;
    width: 384px;
    min-height: 520px;
    max-height: 600px;
    background-color: #111827;
    border-top-left-radius: 25px;
    border-top-right-radius: 25px;
    overflow: hidden;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: max-height 0.3s ease-in-out, width 0.3s ease-in-out, border-radius 0.3s ease-in-out;
    overflow-y: hidden;
}

/***********************************************
   * WHEN MINIMIZED
   ***********************************************/
.chatbox-container.minimized {
    max-height: 56px;
    min-height: 0 !important;
    cursor: pointer;
}

.chatbox-messages,
.chatbox-input,
.chatbox-bottom-spacer {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chatbox-container.minimized .chatbox-messages,
.chatbox-container.minimized .chatbox-input,
.chatbox-container.minimized .chatbox-bottom-spacer {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    height: 0;
    padding: 0;
    margin: 0;
    min-height: 0;
}


/***********************************************
   * HEADER
   ***********************************************/
.chatbox-header {
    position: relative;
    min-height: 3rem;
    display: flex;
    align-items: center;
    padding: 0 0.75rem 0 0.75rem;
    background: linear-gradient(90deg, #15803d, #22c55e, #15803d);
    background-size: 400% 400%;
    animation: gradientFlow 8s ease infinite;
    border-top-left-radius: 25px;
    border-top-right-radius: 25px;
    z-index: 2;
}

/***********************************************
   * LOGO INSIDE HEADER
   ***********************************************/
.chatbox-logo {
    height: 24px;
    margin-right: auto;
}

/***********************************************
   * HEADER ACTIONS
   ***********************************************/
.chatbox-header-actions {
    display: flex;
    align-items: center;
}

.header-icon-button {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-right: 25px;
    margin-bottom: 18px;
    /* adjust spacing from right edge */
    height: 100%;
    /* vertical centering assist */
}

.header-sound-icon {
    margin-right: auto;
    margin-bottom: auto;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 9999px;
    padding: 15px;
    width: 32px;
    height: 32px;
    display: flex;
    font-size: 15px;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.header-sound-ico:hover {
    background-color: rgba(0, 0, 0, 0.25);
}

.header-icon-button:hover,
.header-icon-button:focus {
    color: #d1fae5;
    outline: none;
}

.header-icon-button.compact {
    margin-right: 0;
    margin-bottom: -3px;
}

/***********************************************
   * MESSAGES AREA
   ***********************************************/
.chatbox-messages {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-grow: 1;
    overflow-y: auto;
}

.chat-message {
    display: flex;
    flex-direction: column;
}

/***********************************************
   * BUBBLES / TEXT
   ***********************************************/
.message-meta {
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.25rem;
}

.message-meta.left {
    text-align: left;
}

.message-meta.right {
    text-align: right;
}

.message-bubble {
    padding: 1rem;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    word-break: break-word;
}

/* user bubble */
.user-bubble {
    background: linear-gradient(to left, #16a34a, #14532d);
    border-top-right-radius: 20px;
    border-bottom-left-radius: 20px;
    border-top-left-radius: 0;
    border-bottom-right-radius: 20px;
}

/* admin bubble */
.admin-bubble {
    background: linear-gradient(to right, #16a34a, #14532d);
    border-top-left-radius: 20px;
    border-bottom-right-radius: 20px;
    border-top-right-radius: 0;
    border-bottom-left-radius: 20px;
}

/***********************************************
   * INPUT SECTION
   ***********************************************/
.chatbox-input {
    display: flex;
    align-items: stretch;
    height: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem;
    margin-top: 0.75rem;
}

.chat-input {
    flex-grow: 1;
    min-height: 3rem;
    max-height: 150px;
    resize: vertical;
    padding: 0.5rem;
    background-color: #1f2937;
    border: none;
    outline: none;
    color: rgba(255, 255, 255, 0.9);
    border-radius: 0.5rem;
    margin-right: 0.5rem;
    font-family: inherit;
    line-height: 1.4;
}

/* focus style */
.chat-input:focus {
    outline: 2px solid #22c55e;
    background-color: #273549;
    transition: background-color 0.2s ease;
}

/***********************************************
   * SEND BUTTON
   ***********************************************/
.chat-send-button {
    width: 4rem;
    background-color: #22c55e;
    color: white;
    border: none;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 0.375rem;
}

.chat-send-button:hover,
.chat-send-button:focus {
    background-color: #16a34a;
    transition: background-color 0.2s ease;
}

/***********************************************
   * BOTTOM SPACER
   ***********************************************/
.chatbox-bottom-spacer {
    height: 0.5rem;
    background-color: transparent;
}

/* Spinner Styles */
.rainbow-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    animation: rotateSpinner 1.2s linear infinite;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.25);
}

@keyframes rotateSpinner {
    to {
        transform: rotate(360deg);
    }
}

#chatLoadingSpinner span {
    font-size: 0.9rem;
    /* Slightly larger */
    color: #444;
    /* Darker for contrast */
    font-weight: 600;
    /* Make it bold-ish */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    /* Soft shadow for visibility */
    letter-spacing: 0.3px;
    /* Improves readability slightly */
    animation: pulseText 1.8s ease-in-out infinite;
}

@keyframes pulseText {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.75;
        transform: scale(1.05);
    }
}

/***********************************************
   * ANIMATIONS / MEDIA QUERIES
   ***********************************************/
@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@media (max-width: 768px) {
    .chatbox-header-actions {
        margin-right: 20px;
    }

    .chatbox-container {
        width: 90%;
        right: 4%;
        border-radius: 1rem;
        z-index: 50;
        max-height: 100%;
    }

    .chatbox-container.minimized {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background-color: #111827;
        padding: 0;
        background-image: url('/assets/images/logo/logo-diamond-only.webp');
        background-repeat: no-repeat;
        background-position: center;
        background-size: 65%;
        border: 1px solid rgba(255, 255, 255, 0.06);
        background-color: #15803d;
        z-index: 50;
        bottom: 1rem;
        max-height: 90%;
    }

    .chatbox-container.minimized .chatbox-logo {
        display: none;
    }

    .header-icon-button {
        margin-right: 0;
        margin-left: 5px;
    }

    .chatbox-container.minimized .chatbox-header {
        background: none;
    }

    .chatbox-container.minimized .chatbox-header-actions {
        display: none;
    }

    .chatbox-container.minimized .chatbox-header::after {
        content: '';
        display: none;
    }
}

.typing-effect-bubble {
    background: linear-gradient(270deg, #a0f0a0, #70e070, #a0f0a0);
    background-size: 600% 600%;
    animation: bubbleGlow 2s ease infinite;
}

@keyframes bubbleGlow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes shine {
    from {
        opacity: 0;
        filter: brightness(1.5);
    }

    to {
        opacity: 1;
        filter: brightness(1);
    }
}

@keyframes gentleGlow {
    0% {
        box-shadow: 0 0 4px #15803d, 0 0 8px #15803d;
    }

    50% {
        box-shadow: 0 0 8px #15803d, 0 0 12px #15803d;
    }

    100% {
        box-shadow: 0 0 4px #15803d, 0 0 8px #15803d;
    }
}

.typing-bubble-animated {
    animation: gentleGlow 2s infinite ease-in-out;
}

.chatbox-container.chatbox-shifted {
    right: 2% !important;
    bottom: 5rem !important;
}