/* ==========================================================================
   Chat Page Specific Styles
   Note: This file should be loaded AFTER master.css
   ========================================================================== */

/* ==========================================================================
   Chat Layout Components
   ========================================================================== */
/* Chat box base styles */
.chat-box {
    flex-grow: 1;
    overflow-y: auto;
    padding-bottom: 30px;
    min-height: 0;
}

/* Chat box height variations */
.chat-box {
    height: calc(100vh - 255px);
}

.chat-box.no-media-player {
    height: calc(100vh - 175px);
}

.chat-box.alert-active {
    height: calc(100vh - 330px);
}

.chat-box.no-media-player.alert-active {
    height: calc(100vh - 255px);
}

/* Mobile chat box variations */
.chat-box.mobile {
    height: calc(100vh - 200px);
}

.chat-box.mobile.no-media-player {
    height: calc(100vh - 115px);
}

.chat-box.mobile.alert-active-mobile {
    height: calc(100vh - 265px);
}

.chat-box.mobile.no-media-player.alert-active-mobile {
    height: calc(100vh - 200px);
}

/* Message input */
.message-input {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 0;
    background-color: var(--bs-body-bg);
    z-index: 1000;
    max-width: var(--max-width);
    margin: 0 auto;
}

/* ==========================================================================
   Floating Action Buttons
   ========================================================================== */
.scroll-to-bottom,
.active-users-button {
    position: absolute;
    bottom: 3%;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
}

.scroll-to-bottom {
    right: 10px;
}

.active-users-button {
    left: 10px;
    border-color: ghostwhite;
    opacity: 50%;
}

/* Button position variations */
.scroll-to-bottom.mobile,
.active-users-button.mobile {
    bottom: 2%;
}

.scroll-to-bottom.no-media-player,
.active-users-button.no-media-player {
    bottom: 1%;
}

.scroll-to-bottom.mobile.no-media-player,
.active-users-button.mobile.no-media-player {
    bottom: 1%;
}

.scroll-to-bottom.alert-active,
.active-users-button.alert-active {
    bottom: 5%;
}

/* ==========================================================================
   Audio Player
   ========================================================================== */
.audio-player {
    width: 100%;
    margin: 0 auto 3px;
    padding: 5px 10px 2px;
}

.controls {
    /* margin-top: 5px; */
}

#visualization {
    width: 100%;
    height: 40px;
    padding: 10px 10px 10px;
}

/* Range Input (Volume Slider) */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: rgba(121, 82, 179, 0.3);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover,
input[type="range"]::-webkit-slider-thumb:active {
    background: var(--secondary-color);
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb:hover,
input[type="range"]::-moz-range-thumb:active {
    background: var(--secondary-color);
    transform: scale(1.1);
}

input[type="range"]:active {
    background: rgba(121, 82, 179, 0.5);
}

.form-range {
    width: 100px;
}

/* ==========================================================================
   Messages & Chat-Specific Avatars
   ========================================================================== */
/* Reply styles */
.reply {
    width: 100%;
}

.reply .d-flex {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: flex-start !important;
}

.reply .avatar-placeholder {
    width: var(--avatar-size-small);
    height: var(--avatar-size-small);
    font-size: 0.8em;
    padding-top: 4px;
}

.reply .avatar img.rounded-circle:hover,
.reply .avatar .avatar-placeholder:hover {
    transform: scale(1.1);
}

/* Message content wrapping */
.message-content,
.message-text,
.reply-content,
.reply-text {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    max-width: 100%;
}

.large-emoji > div {
    font-size: 4em;
    line-height: 1.2;
    text-align: left;
}

/* Trash button */
.trash-button {
    width: 38px;
    height: 38px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    padding: 0;
}

/* Emoji reaction */
.emoji-reaction {
    cursor: pointer;
    font-size: 1.75em;
}

/* Custom tooltip */
.custom-tooltip {
    position: absolute;
    z-index: 9999;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    padding: 5px 10px;
    border-radius: var(--border-radius);
    font-size: 14px;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Subscriber username */
.subscriber-username {
    color: var(--primary-color);
}

/* Message hover effect - target the message container */
.chat-messages > div {
    transition: background-color 0.3s ease;
    border-radius: var(--border-radius);
    padding: 5px 0;
}

/* Dark theme hover effect */
body[data-bs-theme="dark"] .chat-messages > div:hover {
    background-color: #2a2a2a; /* Lighter gray than the dark background */
}

/* Light theme hover effect */
body[data-bs-theme="light"] .chat-messages > div:hover {
    background-color: #f0f0f0; /* Slightly darker than typical light background */
}

/* Default hover (for when theme attribute might not be set) */
.chat-messages > div:hover {
    background-color: #2a2a2a; /* Default to dark theme style */
}

/* ==========================================================================
   OG Cards
   ========================================================================== */
.og-data {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 10px 20px 10px 0;
    padding: 10px;
    background-color: transparent;
    border: 2px solid var(--og-border-dark);
    border-radius: var(--border-radius);
    max-width: 540px;
    transition: all 0.3s ease;
}

.og-data:hover {
    border-color: var(--primary-color-accent);
    box-shadow: 0 0 15px rgba(170, 130, 255, 0.4);
}

.og-title {
    margin: 10px;
    font-size: 18px;
    font-weight: bold;
    text-align: justify;
    color: var(--primary-color-bright);
    text-shadow: 0 0 4px rgba(170, 130, 255, 0.4);
    letter-spacing: 0.2px;
}

.og-title a:hover {
    color: var(--primary-color-accent) !important;
    text-shadow: 0 0 6px rgba(170, 130, 255, 0.5);
}

.og-image {
    max-width: 100%;
    max-height: 200px;
    margin: 10px 0;
}

.og-description {
    margin: 10px;
    font-size: 14px;
    text-align: justify;
}

.og-url {
    display: inline-block;
    margin: 5px;
    padding: 5px;
    font-size: 12px;
    color: var(--bs-secondary);
    text-align: center;
    word-wrap: break-word;
    max-width: 100%;
}

/* Dark theme OG card styling */
body[data-bs-theme="dark"] .og-data {
    border-color: var(--og-border-dark);
    box-shadow: 0 0 8px rgba(170, 130, 255, 0.25);
}

body[data-bs-theme="dark"] .og-title {
    color: var(--og-title-dark);
    text-shadow: 0 0 3px rgba(170, 130, 255, 0.3);
}

/* Light theme OG card styling */
body[data-bs-theme="light"] .og-data {
    border-color: var(--og-border-light);
    box-shadow: 0 0 5px rgba(106, 66, 165, 0.15);
}

body[data-bs-theme="light"] .og-title {
    color: var(--og-title-light);
    text-shadow: none;
}

/* Color scheme media queries */
@media (prefers-color-scheme: dark), (data-bs-theme: dark) {
    .og-title {
        color: var(--primary-color-bright, #b49cd6);
        text-shadow: 0 0 3px rgba(121, 82, 179, 0.3);
    }
}

@media (prefers-color-scheme: light), (data-bs-theme: light) {
    .og-title {
        color: #5a3a8a;
        text-shadow: none;
    }
}

/* ==========================================================================
   Media Elements
   ========================================================================== */
/* Video elements */
video {
    width: 90% !important;
    height: auto !important;
}

/* PDF handling */
.pdf-container {
    position: relative;
    width: 100%;
    max-width: 90%;
    overflow: hidden;
}

.pdf-iframe {
    width: 100%;
    height: 0;
    border: none;
    transition: height 0.3s ease;
}

/* YouTube embeds */
.youtube-embed-container {
    margin-top: 10px;
    margin-bottom: 10px;
}

.youtube-embed {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    overflow: hidden;
    background-color: var(--bs-body-bg);
}

.youtube-embed-header {
    display: flex;
    padding: 10px;
    background-color: var(--bs-tertiary-bg);
    border-bottom: 1px solid var(--bs-border-color);
}

.youtube-thumbnail {
    width: 120px;
    height: 67px;
    object-fit: cover;
    margin-right: 10px;
    border-radius: var(--bs-border-radius-sm);
}

.youtube-info {
    flex: 1;
}

.youtube-title {
    margin: 0 0 5px 0;
    font-size: 14px;
    font-weight: bold;
    color: var(--bs-body-color);
}

.youtube-author {
    margin: 0;
    font-size: 12px;
    color: var(--bs-secondary-color);
}

.youtube-embed-footer {
    padding: 10px;
    background-color: var(--bs-tertiary-bg);
    border-top: 1px solid var(--bs-border-color);
    text-align: right;
}

/* Responsive embeds */
.embed-responsive {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    overflow: hidden;
}

.embed-responsive::before {
    content: "";
    display: block;
    padding-top: 56.25%;
}

.embed-responsive iframe {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ==========================================================================
   Emoji, GIF, and Tenor Integration
   ========================================================================== */
.giphy-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.giphy-item {
    cursor: pointer;
}

#tenorModal .modal-dialog {
    max-width: 900px;
}

#tenorModal .modal-content {
    height: 90vh;
    display: flex;
    flex-direction: column;
}

#tenorModal .modal-body {
    flex: 1;
    overflow-y: auto;
}

.tenor-item {
    cursor: pointer;
    transition: transform 0.2s;
}

.tenor-item:hover {
    transform: scale(1.05);
}

.tenor-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

/* ==========================================================================
   Scrollbar Customization
   ========================================================================== */
/* Discord-style scrollbar */
.chat-box::-webkit-scrollbar {
    width: 8px;
}

.chat-box::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 10px;
}

.chat-box::-webkit-scrollbar-thumb {
    background: #a8adb4;
    border-radius: 100px;
    border: 2px solid transparent;
    background-clip: content-box;
    min-height: 40px;
}

.chat-box::-webkit-scrollbar-thumb:hover {
    background: #ccced1;
    background-clip: content-box;
}

.chat-box::-webkit-scrollbar-button {
    display: none;
}

/* Firefox scrollbar support */
.chat-box {
    scrollbar-width: thin;
    scrollbar-color: #a8adb4 transparent;
}

/* ==========================================================================
   Mentions Styles for Chat
   ========================================================================== */

.mention-display {
    background-color: #5865f2;
    color: white;
    padding: 6px 6px 7px;
    border-radius: 3px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-decoration: none;
    margin: 5px;
}

.mention-display:hover {
    background-color: #4752c4;
    color: white;
}

/* Mention in message input (during composition) */
.mention {
    background-color: #e3f2fd;
    color: #1976d2;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: 500;
    border: 1px solid #bbdefb;
}

/* Dark mode support */
[data-bs-theme="dark"] .mention-display {
    background-color: #5865f2;
    color: white;
}

[data-bs-theme="dark"] .mention-display:hover {
    background-color: #4752c4;

}

[data-bs-theme="dark"] .mention {
    background-color: #1e3a8a;
    color: #93c5fd;
    border-color: #3b82f6;
}

/* Mention search modal styling */
.mention-results {
    max-height: 300px;
    overflow-y: auto;
}

.mention-results .list-group-item {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.mention-results .list-group-item:hover {
    background-color: var(--bs-list-group-hover-bg);
}

/* Avatar styling in mention search */
.mention-results .avatar-container {
    flex-shrink: 0;
}

.mention-results .avatar-placeholder {
    flex-shrink: 0;
}

/* ==========================================================================
   Mobile Responsive Styles for Chat
   ========================================================================== */
@media (max-width: 767px) {
    .chat-container,
    .message-input,
    .chat-box,
    .chat-messages {
        margin: 0;
        padding: 0;
        max-width: 100%;
        width: 100%;
        overflow-x: hidden;
    }

    .message-content {
        padding-right: 5px;
    }

    .reply .avatar {
        margin-right: 5px !important;
    }

    .reply-content {
        padding-right: 25px;
    }

    .reply .delete-button .btn {
        padding: 2px;
        font-size: 0.75rem;
    }

    .audio-player {
        max-width: 100%;
        padding: 5px;
    }

    .form-range {
        width: 60px;
    }

    .chat-container {
        padding: 55px 5px 5px;
    }

    .scroll-to-bottom,
    .active-users-button {
        bottom: 70px;
    }

    .chat-box.alert-active {
        height: calc(100vh - 500px);
    }

    .og-data {
        margin: 10px 0 0 0;
        max-width: 100%;
        padding: 8px;
    }

    .og-title {
        font-size: 14px;
    }

    .og-description {
        font-size: 12px;
    }

    .og-image {
        max-height: 150px;
    }
}