.chat-container-toggle{
    display: flex !important;
    height: 100%;
    width: max-content;
    gap: 5px;
    align-items: center;
    position: relative;
    z-index: 13;
}
.chat-container-toggle i{
    display: inline;
}
.chat-container-toggle .dot{
    width: 6px;
    height: 6px;
    border-radius: 10px;
    background-color: var(--highlight-red);
}

/* -------------------- Chat Container Start -------------------- */

.chat-container{
    height: 100%;
    width: 100%;
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 101;
    overflow-y: hidden;
    scrollbar-width: none;
    color: var(--color-text-1);
    background: var(--bg-gradient-3);
}

.chat-container.active{
    display: block;
}

/* ==================== SIDEBAR HEADER (Telegram-style) ==================== */
.sidebar-header {
    position: sticky;
    top: 0;
    z-index: 3;
    width: 100%;
    min-height: 54px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.875rem;
    background: var(--bg-color-2);
    border-bottom: 1px solid var(--bg-color-5);
}

.sidebar-header-title {
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.2px;
    color: var(--color-text-1);
}

.sidebar-header i {
    cursor: pointer;
    color: var(--color-text-2);
    transition: color 0.15s ease;
}

.sidebar-header i:hover {
    color: var(--color-text-1);
}

.sidebar-close {
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.15s ease;
    border: none;
    color: var(--color-dark-5);
}

.sidebar-close:hover {
    background-color: var(--bg-color-4);
    color: var(--color-text-1);
}

/* ==================== TELEGRAM-STYLE CHAT WINDOW HEADER ==================== */
.chat-window-header {
    position: sticky;
    top: 0;
    z-index: 3;
    width: 100%;
    height: 56px; /* Telegram standard header height */
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0.75rem;
    background: var(--bg-color-2);
    border-bottom: 1px solid var(--bg-color-5);
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.chat-window-header.active {
    background: var(--bg-gradient-3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Back Button - Minimalist Design */
.header-back-btn {
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    border: none;
    color: var(--color-text-2);
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.15s ease;
    flex-shrink: 0;
}

.header-back-btn:hover {
    color: var(--color-text-1);
    transform: translateX(-2px);
}

.header-back-btn:active {
    transform: translateX(-4px);
}

/* Contact Info Section - Clickable (Facebook Messenger style) */
.header-contact-info {
    flex: 0 1 auto; /* Take only needed space for tight hover background */
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0; /* Allow text truncation */
    padding: 0.5rem;
    margin: -0.5rem; /* Expand clickable area */
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
}

.header-contact-info:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .header-contact-info:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.header-contact-info:active {
    background-color: rgba(255, 255, 255, 0.12);
}

[data-theme="light"] .header-contact-info:active {
    background-color: rgba(0, 0, 0, 0.08);
}

/* Dropdown Arrow Icon (Facebook Messenger style) */
.header-dropdown-icon {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-left: 0.5rem; /* Tight spacing next to username */
    transition: transform 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

[data-theme="light"] .header-dropdown-icon {
    color: rgba(0, 0, 0, 0.4);
}

.header-contact-info:hover .header-dropdown-icon {
    color: rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .header-contact-info:hover .header-dropdown-icon {
    color: rgba(0, 0, 0, 0.6);
}

/* Rotate arrow when dropdown is open */
.header-contact-info.menu-open .header-dropdown-icon {
    transform: rotate(180deg);
}

/* Avatar in Header */
.header-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.header-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* Online Status Indicator */
.header-status-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-color-2);
    background: var(--color-dark-5); /* Offline by default */
}

.header-status-indicator.online {
    background: var(--highlight-teal);
}

.header-status-indicator.away {
    background: var(--highlight-orange);
}

.header-status-indicator.busy {
    background: var(--highlight-red);
}

/* User Details (Name + Status) */
.header-user-details {
    flex: 0 1 auto; /* Take only needed space, not all available space */
    min-width: 0;
    max-width: 100%; /* Still allow shrinking for responsiveness */
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.125rem;
}

.header-username {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--color-text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-order-number {
    font-size: 12px;
    font-weight: 400;
    color: var(--color-text-3);
    opacity: 0.7;
    flex-shrink: 0;
}

.header-status-text {
    font-size: 13px;
    line-height: 1.2;
    color: var(--color-text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.7;
}

/* When user is online, show in accent color */
.header-status-text.online {
    color: var(--accent-2);
    opacity: 1;
}

/* Right Action Buttons - Minimalist Design */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
    margin-left: auto; /* Push to right corner */
}

.header-action-btn,
.header-close-btn {
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    border: none;
    color: var(--color-text-2);
    font-size: 17px;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.15s ease;
    flex-shrink: 0;
}

.header-action-btn:hover,
.header-close-btn:hover {
    color: var(--color-text-1);
    transform: scale(1.1);
}

.header-action-btn:active,
.header-close-btn:active {
    transform: scale(0.95);
}

/* Close button specific styling */
.header-close-btn {
    font-size: 18px;
}

.header-close-btn:hover {
    color: var(--highlight-red);
}

.chat-body{
    position: relative;
    box-sizing: border-box;
    height: 100%;
    min-height: 400px;
    z-index: 1;
    background: var(--bg-gradient-3);
}

.overlay-gradient.active{
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100px;
    z-index: -2;
    background: var(--bg-gradient-1-reverse);
}


/* ==================== TELEGRAM-STYLE CHAT LIST ==================== */

/* Chat Contact Container */
.chat-contact-container {
    position: relative;
    display: none;
    height: 100%;
    min-height: 400px;
    background: var(--bg-color-2);
}

.chat-contact-container.active {
    display: flex;
    flex-direction: column;
}

/* ==================== SIDEBAR TABS (Facebook/Telegram Style) ==================== */

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--bg-color-4);
    background: var(--bg-color-2);
    padding: 0 0.5rem;
    gap: 0.25rem;
}

.sidebar-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 15px;
    font-weight: 500;
    color: var(--color-text-2);
    opacity: 0.7;
    position: relative;
}

.sidebar-tab:hover {
    opacity: 1;
    background-color: var(--bg-color-3);
    border-radius: 0.5rem 0.5rem 0 0;
}

.sidebar-tab.active {
    color: var(--accent-2);
    opacity: 1;
    border-bottom-color: var(--accent-2);
}

.sidebar-tab.active:hover {
    background-color: transparent;
}

.sidebar-tab .tab-label {
    font-weight: 500;
}

.sidebar-tab.active .tab-label {
    font-weight: 600;
}

/* Tab Badge (Active count) */
.sidebar-tab .tab-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 0.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    background: var(--accent-gradient-2);
    color: var(--static-1);
}

.sidebar-tab .tab-count {
    font-size: 13px;
    opacity: 0.6;
}

/* Tab Content Panels */
.sidebar-tab-panels {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.sidebar-tab-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sidebar-tab-content.active {
    opacity: 1;
    visibility: visible;
    position: relative;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    color: var(--color-text-2);
    opacity: 0.5;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
    margin: 0;
}

/* Sidebar Contacts List Scrollable Area (Telegram-style) */
.sidebar-contacts-list {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-color-6) transparent;
    padding-bottom: 0;
    box-sizing: border-box;
}

.sidebar-contacts-list::-webkit-scrollbar {
    width: 6px;
}

.sidebar-contacts-list::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-contacts-list::-webkit-scrollbar-thumb {
    background: var(--bg-color-6);
    border-radius: 3px;
}

.sidebar-contacts-list::-webkit-scrollbar-thumb:hover {
    background: var(--color-dark-5);
}

/* Chat Messages List Scrollable Area (Telegram-style scrollbar) */
.chat-messages-list {
    flex: 1 1 auto;
    overflow-y: scroll;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: transparent transparent; /* Hidden by default in Firefox */
    padding-bottom: 12px; /* Reduced from 50px - compact like Telegram */
    height: 400px;
    box-sizing: border-box;
}

/* Webkit scrollbar styling (Chrome, Safari, Edge) */
.chat-messages-list::-webkit-scrollbar {
    width: 6px; /* Slim scrollbar */
}

.chat-messages-list::-webkit-scrollbar-track {
    background: transparent; /* Invisible track */
}

.chat-messages-list::-webkit-scrollbar-thumb {
    background: transparent; /* Hidden by default */
    border-radius: 3px;
    transition: background 0.2s ease;
}

/* Show scrollbar on hover (Telegram behavior) */
.chat-messages-list:hover::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2); /* Light gray, subtle */
}

.chat-messages-list:hover::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4); /* Darker when hovering the thumb itself */
}

/* Firefox: Show scrollbar on hover */
.chat-messages-list:hover {
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

/* Dark theme adjustments */
html[data-theme='dark'] .chat-messages-list:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

html[data-theme='dark'] .chat-messages-list:hover::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

html[data-theme='dark'] .chat-messages-list:hover {
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Section Titles (Telegram-style) */
.contact-section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.875rem 0.75rem 0.5rem 0.875rem;
    margin-top: 0.5rem;
    color: var(--color-text-2);
    opacity: 0.65;
}

.contact-section-title:first-child {
    margin-top: 0;
    padding-top: 0.625rem;
}

/* Chat Contact Item (Telegram-style) */
.chat-contact {
    width: 100%;
    display: flex;
    cursor: pointer;
    align-items: center;
    padding: 0.625rem 0.875rem;
    transition: background-color 0.1s ease;
    border-bottom: none;
    position: relative;
}

.chat-contact:hover {
    background-color: var(--bg-color-3);
}

/* Active/Selected Chat */
.chat-contact.active {
    background-color: var(--bg-color-4);
}

.chat-contact.active:hover {
    background-color: var(--bg-color-4);
}

/* Separator between chat items */
.chat-contact:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 67px; /* Avatar (52px) + margin (0.875rem ≈ 14px) + padding-left (0.875rem ≈ 14px) - offset for visual alignment */
    right: 0.875rem;
    height: 1px;
    background-color: var(--bg-color-4);
    opacity: 0.35;
}

/* Avatar (Telegram: larger, 52px) */
.chat-contact-img {
    width: 52px;
    height: 52px;
    min-width: 52px;
    min-height: 52px;
    border-radius: 50%;
    position: relative;
    margin-right: 0.875rem;
}

.chat-contact-img img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* Online Status Indicator (Telegram-style) */
.chat-contact-img .active-status {
    width: 14px;
    height: 14px;
    position: absolute;
    bottom: 0;
    right: 0;
    border-radius: 50%;
    border: 2px solid var(--bg-color-2);
    padding: 0;
    overflow: hidden;
    background: var(--color-dark-5);
}

.chat-contact-img .active-status .wrapper {
    width: 100%;
    height: 100%;
    position: relative;
}

.chat-contact-img .active-status.online {
    background: var(--highlight-teal);
}

.chat-contact-img .active-status.away {
    background: var(--highlight-orange);
}

.chat-contact-img .active-status.away .el {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color-2);
    transform: translate(-50%, -40%);
}

.chat-contact-img .active-status.busy {
    background: var(--highlight-red);
}

.chat-contact-img .active-status.busy .el {
    position: absolute;
    top: 50%;
    left: 50%;
    height: 2px;
    width: 6px;
    background: var(--bg-color-2);
    transform: translate(-50%, -50%);
}

/* Contact Info Container */
.chat-contact-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.1875rem;
    padding: 0.125rem 0;
}

/* Top Row: Name + Time */
.chat-contact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.125rem;
}

.chat-contact-info .contact-name {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--color-text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.chat-contact-info .contact-time {
    font-size: 12px;
    line-height: 1.3;
    color: var(--color-text-2);
    white-space: nowrap;
    flex-shrink: 0;
    opacity: 0.55;
    margin-top: 1px;
}

/* Bottom Row: Last Message + Unread Badge */
.chat-contact-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.chat-contact-info .contact-msg {
    font-size: 14px;
    line-height: 1.35;
    color: var(--color-text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    opacity: 0.75;
}

.chat-contact-info .contact-order-id {
    color: var(--accent-2);
    font-weight: 600;
    margin-right: 0.35rem;
}

.chat-contact-info .contact-last-msg {
    color: var(--color-text-2);
    opacity: 0.75;
}

/* Unread Badge (Telegram-style: rounded blue) */
.chat-contact-info .msg-notification {
    min-width: 20px;
    height: 20px;
    padding: 0 0.35rem;
    font-size: 12px;
    font-weight: 600;
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    background: var(--accent-gradient-2);
    color: var(--static-1);
    flex-shrink: 0;
}

/* Show badge when it has content */
.chat-contact-info .msg-notification:not(:empty) {
    display: flex;
}

/* Show badge when explicitly visible */
.chat-contact-info .msg-notification.visible {
    display: flex;
}

/* Active Chat Styling */
.chat-contact.active .contact-name {
    font-weight: 600;
}

.chat-contact.active .contact-msg {
    font-weight: 500;
}

/* Archived Chat Styling */
.chat-contact.archived {
    opacity: 0.8;
}

.chat-contact.archived .contact-name {
    color: var(--color-text-2);
}

.chat-contact.archived .active-status {
    display: none; /* Hide online status for archived chats */
}

.chat-contact.archived:hover {
    opacity: 1;
}

/* Orders without chat history - non-clickable, muted */
.chat-contact.no-chat-history {
    cursor: default;
    opacity: 0.65;
}

.chat-contact.no-chat-history:hover {
    background-color: transparent;
}

.chat-contact.no-chat-history .contact-last-msg.no-messages {
    font-style: italic;
    opacity: 0.8;
}


/* ==================== THEME-SPECIFIC OVERRIDES ==================== */

/* Light Theme Adjustments */
html[data-theme='light'] .chat-contact-container {
    background: var(--bg-color-6);
}

html[data-theme='light'] .sidebar-header {
    background: var(--bg-color-6);
    border-bottom: 1px solid var(--bg-color-4);
}

html[data-theme='light'] .chat-contact {
    border-bottom: 1px solid var(--bg-color-3);
}

html[data-theme='light'] .chat-contact:hover {
    background-color: var(--bg-color-1);
}

html[data-theme='light'] .chat-contact.active {
    background-color: var(--bg-color-3);
}

html[data-theme='light'] .sidebar-contacts-list::-webkit-scrollbar-thumb {
    background: var(--bg-color-4);
}

html[data-theme='light'] .sidebar-contacts-list::-webkit-scrollbar-thumb:hover {
    background: var(--bg-color-5);
}

/* Light theme text adjustments - darker colors for better contrast */
html[data-theme='light'] .contact-section-title {
    color: var(--color-dark-2);
    opacity: 0.7;
}

html[data-theme='light'] .chat-contact-info .contact-time {
    color: var(--color-dark-2);
    opacity: 0.6;
}

html[data-theme='light'] .chat-contact-info .contact-msg {
    color: var(--color-dark-2);
    opacity: 0.8;
}

html[data-theme='light'] .chat-contact-info .contact-last-msg {
    color: var(--color-dark-2);
    opacity: 0.8;
}

html[data-theme='light'] .chat-contact:not(:last-child)::after {
    background-color: var(--bg-color-3);
    opacity: 0.5;
}

/* Light theme tab adjustments */
html[data-theme='light'] .sidebar-tabs {
    border-bottom: 1px solid var(--bg-color-3);
    background: var(--bg-color-6);
}

html[data-theme='light'] .sidebar-tab {
    color: var(--color-dark-2);
}

html[data-theme='light'] .sidebar-tab:hover {
    background-color: var(--bg-color-1);
}

html[data-theme='light'] .sidebar-tab.active {
    color: var(--accent-1);
    border-bottom-color: var(--accent-1);
}

html[data-theme='light'] .contact-search.read-only-footer {
    background: var(--bg-color-6);
    border-top: 1px solid var(--bg-color-4);
}

html[data-theme='light'] .archived-footer-content {
    background: var(--bg-color-6);
    border: 1px solid var(--bg-color-4);
}

html[data-theme='light'] .archived-message {
    color: var(--color-dark-2);
}

html[data-theme='light'] .archived-footer-content .donate-btn {
    color: var(--color-dark-3) !important;
    background: transparent !important;
}

html[data-theme='light'] .archived-footer-content .donate-btn:hover {
    color: #FFB900 !important; /* Same gold color in both themes */
    opacity: 1 !important;
    background: transparent !important;
}

/* Light theme - Header adjustments */
html[data-theme='light'] .chat-window-header {
    background: var(--bg-color-6);
    border-bottom: 1px solid var(--bg-color-4);
}

html[data-theme='light'] .header-back-btn {
    color: var(--color-dark-3);
}

html[data-theme='light'] .header-back-btn:hover {
    color: var(--color-dark-1);
}

html[data-theme='light'] .header-status-indicator {
    border-color: var(--bg-color-6);
}

html[data-theme='light'] .header-close-btn {
    color: var(--color-dark-3);
}

html[data-theme='light'] .header-close-btn:hover {
    color: var(--highlight-red);
}

/* ========== TELEGRAM-STYLE INPUT AREA ========== */
.contact-search{
    position: sticky;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 0.65rem 0.9rem;
    background: var(--bg-color-2);
    border-top: 1px solid var(--bg-color-6);
    z-index: 5;
}

.contact-search .overlay-gradient {
    display: none; /* Hide overlay gradient for cleaner look */
}

.search-box{
    display: flex;
    align-items: center;
    position: relative;
    border-radius: 20rem;
    color: var(--color-text-1) !important;
    border: 1px solid transparent;
    background-color: var(--bg-color-3) !important;
}

.search-box.active{
    border-color: var(--accent-1);
}

.search-box i{
    position: absolute;
    left: 0;
    margin-left: 1.5rem;
}

.search-box input{
    width: 100%;
    height: 100%;
    font-size: 13px;
    outline: none;
    border:none;
    padding: 0.6rem 4rem;
    background-color: transparent;
    color: var(--color-text-1) !important;
}

/* Chat Message Tab */
.chat-message-container{
    display: none;
    position: relative;
    height: 100%;
    min-height: 400px;
}
.chat-message-container.active{
    display: flex !important;
    flex-direction: column;
    justify-content: space-between;
}

/* Load More Messages Button */
.load-more-messages {
    display: none;
    text-align: center;
    padding: 10px;
}

.load-more-messages.visible {
    display: block;
}

/* ==================== TIP MESSAGES ==================== */

.tip-info-wrapper{
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 5px;
}

.tip-info-wrapper .icon-container{
    background-color: var(--static-1);
    height: 30px;
    width: 30px;
    border-radius: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--accent-1);
}

/* Receiving Tip */
.receiving-tip-container{
    display: flex;
    justify-content: start;
    padding: 0.5rem 2rem;
}
.receiving-tip{
    width: auto;
    max-width: 250px;
    padding: 0.8rem 1rem;
    border-radius: 0.6rem;
    background-color: var(--bg-color-6);
}
.receiving-tip .name{
    font-size: 8px;
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 0.1rem;
    text-transform: uppercase;
    color: var(--color-dark-5);}

.receiving-tip .message{
    background: var(--accent-gradient-1);
    padding: 15px;
    border-radius: 10px;
    font-size: 13px;
    font-family: var(--font-family-2), serif !important;
    color: var(--static-1);
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.receiving-tip .time{
    text-align: end;
    font-size: 8px;
    letter-spacing: 1px;
    font-weight: 700;
    margin-top: 0.5rem;
    text-transform: uppercase;
    color: var(--color-dark-5);
}

/* Sending Tips */
.sending-tip-container{
    display: flex;
    justify-content: end;
    padding: 0.5rem 2rem;
}

.sending-tip{
    width: auto;
    max-width: 250px;
    padding: 0.8rem 1rem;
    border-radius: 0.6rem;
    background: var(--accent-gradient-2);
}

.sending-tip .tip-info-wrapper .icon-container{
    border: 1px solid var(--accent-1);
}
.sending-tip *{
    pointer-events: none;
}
.sending-tip .name{
    font-size: 8px;
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 0rem;
    text-transform: uppercase;
    color: var(--static-1);
}
.sending-tip .message{
    background-color: var(--bg-color-1);
    padding: 15px;
    border-radius: 10px;
    font-size: 13px;
    font-family: var(--font-family-2), serif !important;
    color: var(--color-text-1);
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.sending-tip .time{
    text-align: end;
    font-size: 8px;
    letter-spacing: 1px;
    font-weight: 700;
    margin-top: 0.5rem;
    text-transform: uppercase;
    color: var(--static-1);
}

/* Telegram-style input container - horizontal layout */
.text-box{
    display: flex;
    flex-direction: row;
    align-items: center; /* Center for proper baseline alignment */
    gap: 0.4rem;
    position: relative; /* For emoji picker positioning */
    background-color: var(--bg-color-3);
    border-radius: 1.25rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--bg-color-6);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.text-box:has(textarea:focus){
    border-color: var(--accent-1);
    box-shadow: 0 0 0 2px rgba(64, 167, 227, 0.1);
}

.text-box:focus-within{
    border-color: var(--accent-1);
}

.text-box i:hover{
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

/* Telegram-style contenteditable input - supports Twemoji like real Telegram */
.text-box .message-input {
    flex: 1;
    min-width: 0; /* Allow flexbox to shrink below content size */
    scrollbar-width: thin;
    box-sizing: border-box;
    background-color: transparent;
    overflow-y: auto; /* Allow scrolling when needed */
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    color: var(--color-text-1) !important;
    min-height: 24px;
    max-height: 120px; /* Max 5 lines before scroll */
    padding: 0 0.5rem;
    margin: 0;
    outline: none !important;
    border: none;
    font-size: 15px;
    line-height: 24px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    white-space: pre-wrap; /* Preserve line breaks */
}

/* Placeholder for empty contenteditable */
.text-box .message-input:empty::before {
    content: attr(data-placeholder);
    color: var(--color-dark-5);
    opacity: 0.7;
    pointer-events: none;
}

/* Twemoji in contenteditable input */
.text-box .message-input img.chat-emoji {
    height: 1.3em;
    width: 1.3em;
    vertical-align: -0.2em;
    margin: 0 0.05em;
}

/* Show scrollbar only when content overflows */
.text-box .message-input::-webkit-scrollbar {
    width: 4px;
}

.text-box .message-input::-webkit-scrollbar-thumb {
    background-color: var(--bg-color-6);
    border-radius: 2px;
}

.text-box .message-input::-webkit-scrollbar-track {
    background: transparent;
}

/* Telegram-style left actions (emoji, attachment) */
.text-box .left-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.text-box .left-actions span {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    cursor: pointer;
    color: var(--color-dark-5);
    font-size: 21px;
    transition: color 0.15s ease, opacity 0.15s ease;
}

/* Telegram doesn't use circle backgrounds on hover */
.text-box .left-actions span:hover {
    color: var(--color-text-1);
    opacity: 0.8;
}

.text-box .left-actions span.active {
    color: var(--accent-1);
}

/* Telegram-style send button - simple icon without circle */
.text-box .send-message {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    cursor: pointer;
    background: transparent;
    transition: opacity 0.15s ease, filter 0.15s ease;
}

.text-box .send-message .send-icon {
    width: 26px;
    height: 26px;
    display: block;
    /* Color the SVG using CSS filter to achieve #40A7E3 (Telegram blue) */
    filter: invert(54%) sepia(82%) saturate(1217%) hue-rotate(169deg) brightness(94%) contrast(89%);
}

.text-box .send-message:hover .send-icon {
    /* Slightly darker blue on hover (#3A9ADB) */
    filter: invert(50%) sepia(72%) saturate(1380%) hue-rotate(169deg) brightness(92%) contrast(87%);
    opacity: 0.9;
}

.text-box .send-message:active .send-icon {
    opacity: 0.6;
}

/* Tip button styling - clear icon without circular hover */
.text-box .donate-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    margin-left: 0.15rem;
    cursor: pointer;
    color: var(--color-dark-5);
    font-size: 20px;
    transition: color 0.15s ease, opacity 0.15s ease;
}

.text-box .donate-btn:hover {
    color: #FFB900; /* Gold color for tips */
    opacity: 0.8;
}

.text-box .donate-btn:active {
    opacity: 0.6;
}

/* ==================== READ-ONLY FOOTER (Archived Chats) ==================== */

.contact-search.read-only-footer {
    padding: 0.5rem 0.65rem;
    z-index: 5;
    background: var(--bg-color-2);
    border-top: 1px solid var(--bg-color-5);
}

.archived-footer-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.65rem;
    border-radius: 1.25rem;
    background: var(--bg-color-2);
    border: 1px solid var(--bg-color-6);
}

.archived-message {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-2);
    opacity: 0.7;
    font-size: 14px;
    min-width: 0;
}

.archived-message i {
    font-size: 16px;
    opacity: 0.6;
    flex-shrink: 0;
}

.archived-message span {
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tip button in archived chat - EXACTLY matches active chat .donate-btn style */
.archived-footer-content .donate-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    margin-left: 0.15rem;
    cursor: pointer;
    color: var(--color-dark-5);
    font-size: 20px;
    transition: color 0.15s ease, opacity 0.15s ease;
    flex-shrink: 0;
    /* Explicitly remove any circular background styling */
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.archived-footer-content .donate-btn:hover {
    color: #FFB900 !important;
    opacity: 0.8 !important;
    filter: none !important;
    background: transparent !important;
}

.archived-footer-content .donate-btn:active {
    opacity: 0.5;
    background: transparent !important;
}

/* Telegram-style emoji picker - positioned above input */
/* ==================== EMOJI PICKER - Telegram Style with Twemoji ==================== */

.emoji-picker{
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 0.4rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-color-3);
    border: 1px solid var(--bg-color-6);
    border-radius: 0.875rem;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
    max-height: 280px;
    z-index: 10;
}

/* Emoji Search Container */
.emoji-search-container {
    position: relative;
    padding: 0.75rem 0.75rem 0.5rem 0.75rem;
    border-bottom: 1px solid var(--bg-color-6);
    flex-shrink: 0;
}

.emoji-search-input {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    background: var(--bg-color-1);
    border: 1px solid var(--bg-color-6);
    border-radius: 0.5rem;
    color: var(--color-text-1);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.emoji-search-input:focus {
    border-color: #5b9fff;
}

.emoji-search-input::placeholder {
    color: var(--color-text-3);
    opacity: 0.6;
}

.emoji-search-icon {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-3);
    opacity: 0.5;
    pointer-events: none;
}

/* Emoji Grid */
.emoji-grid {
    padding: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    overflow-y: auto;
    scrollbar-width: thin;
    flex: 1;
}

.emoji-grid::-webkit-scrollbar {
    width: 6px;
}

.emoji-grid::-webkit-scrollbar-track {
    background: transparent;
}

.emoji-grid::-webkit-scrollbar-thumb {
    background: var(--bg-color-5);
    border-radius: 3px;
}

.emoji-grid::-webkit-scrollbar-thumb:hover {
    background: var(--bg-color-6);
}

/* No Results Message */
.emoji-no-results {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.emoji-no-results-icon {
    font-size: 48px;
    margin-bottom: 0.5rem;
}

.emoji-no-results-text {
    color: var(--color-text-3);
    font-size: 14px;
}

.emoji-picker::-webkit-scrollbar-thumb {
    background-color: var(--bg-color-6);
    border-radius: 3px;
}

/* Emoji items - works with both native emojis and Twemoji */
.emoji-grid span {
    cursor: pointer;
    font-size: 1.45rem; /* For native emoji fallback */
    line-height: 1;
    padding: 0.35rem;
    border-radius: 0.4rem;
    transition: background-color 0.15s ease, transform 0.1s ease;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.emoji-grid span:hover {
    background-color: var(--bg-color-4);
    transform: scale(1.15);
}

.emoji-grid span:active {
    transform: scale(1.05);
}

/* Backward compatibility for non-chat donate buttons */
.donate-btn:not(.text-box .donate-btn):not(.archived-footer-content .donate-btn){
    background-color: var(--accent-1);
    height: 30px;
    width: 30px;
    box-sizing: border-box;
    color: var(--static-1);
    border-radius: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 0;
    cursor: pointer;
}

.donate-btn:not(.text-box .donate-btn):not(.archived-footer-content .donate-btn):hover{
    filter: brightness(1.2);
}

.donate-btn:not(.text-box .donate-btn):not(.archived-footer-content .donate-btn) i{
    margin-left: 0;
    color: var(--static-1);
}

.tip-modal{
    background-color: rgba(0, 0, 0, .75);
    opacity: 1;
    height: 100%;
    width: 100%;
    padding: 2rem;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 10;
    display: none;
    align-items: center;
}
.tip-modal.active{
    display: flex;
}
.tip-container{
    background: var(--bg-gradient-2);
    height: max-content;
    width: 100%;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    box-sizing: border-box;
    position: relative;
    border-radius: 20px;
    border: 1px solid var(--accent-1);
}

.tip-container .section-3{
    width: 80%;
}

.tip-container .close-btn{
    margin-left: auto;
    margin-right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    top: 20px;
    right: 20px;
    height: 35px;
    width: 35px;
    font-size: 18px;
    cursor: pointer;
    border-radius: 40px;
    border: 1px solid var(--color-dark-5);
    color: var(--color-dark-5);
}
.tip-container .close-btn:hover{
    filter: brightness(1.2);
}

.tip-container form{
    margin: 0;
}

.tip-container textarea{
    max-height: 150px !important;
    resize: none;
    padding-left: 0.8rem;
}

.tip-container textarea:focus{
    filter: brightness(1.2);
}

.tip-container .btn{
    margin: 0.8rem 0 0 0;
}

/* ==================== IMAGE GALLERY ==================== */

.chat-images-container{
    display: none;
}

.chat-images-container.active{
    display: block;
}

.img-modal{
    cursor: pointer;
}

.images-container{
    padding: 1rem 2rem;
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
}

.img-wrapper{
    max-width: 70px;
    max-height: 70px;
    border-radius: 10px;
    overflow: hidden;
}

.img-wrapper img{
    height: 100%;
    width: 100%;
    object-fit: cover;
}

/* ==================== ENHANCED CHAT DROPDOWN MENU ==================== */

/* Chat Header Actions Container */
.chat-header-actions {
    position: fixed; /* Fixed positioning to place outside chat */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none; /* Allow clicks through */
    z-index: 9994; /* Just below dropdown */
}

.chat-header-actions > * {
    pointer-events: auto; /* Re-enable clicks on dropdown itself */
}

/* ==================== CHAT DROPDOWN MENU ==================== */
/* Dropdown menu styles have been moved to: public/css/modals/chat-dropdown.css
   HTML template: templates/modals/chat_dropdown.html.twig
   
   This keeps all modal-related code organized together for:
   - Easier maintenance
   - Better code organization
   - Consistent modal patterns across the app
*/

/* ==================== RESPONSIVE STYLES ==================== */

/* iPads, Tablets */
@media (min-width: 768px) {
    .chat-container-toggle .dot{
        position: absolute;
        top: 50%;
        right: -2px;
        width: 8px;
        height: 8px;
        transform: translateY(-100%);
    }
    .chat-container-toggle i{
        display: inline;
    }
    .chat-container-toggle span{
        display: none;
    }

    /* -------------------- Chat Container Start -------------------- */
    .chat-container{
        height: auto;
        min-height: 400px;
        max-height: 650px;
        width: 450px;
        border-radius: 1rem;
        margin-top: 3.5rem;
        top: 0;
        left: unset;
        right: 12rem; /* Moved more to the left to prevent context menu cutoff */
        border: 1px solid var(--accent-1);
        -webkit-box-shadow: var(--box-shadow-dark-3);
        -moz-box-shadow: var(--box-shadow-dark-3);
        box-shadow: var(--box-shadow-dark-3);
    }
    /* -------------------- Chat Container End -------------------- */
}

/* ==================== CHAT RESPONSIVE STYLES ==================== */

/* Tablet Adjustments */
@media (max-width: 768px) {
    /* Header adjustments for tablet */
    .chat-window-header {
        padding: 0 0.5rem;
        gap: 0.5rem;
    }
    
    .header-back-btn,
    .header-action-btn,
    .header-close-btn {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }
    
    .header-close-btn {
        font-size: 17px;
    }
    
    .header-back-btn {
        font-size: 16px;
    }
    
    .header-avatar {
        width: 36px;
        height: 36px;
    }
    
    .header-status-indicator {
        width: 10px;
        height: 10px;
    }
    
    .header-username {
        font-size: 14px;
    }
    
    .header-status-text {
        font-size: 12px;
    }
    
    .archived-footer-content {
        padding: 0.45rem 0.6rem;
        gap: 0.35rem;
    }
    
    .archived-message {
        font-size: 13px;
        gap: 0.4rem;
    }
    
    .archived-message i {
        font-size: 15px;
    }
    
    .archived-footer-content .donate-btn {
        width: 30px;
        height: 30px;
        font-size: 19px;
        margin-left: 0.1rem;
    }
    
    /* Telegram input adjustments for tablet */
    .contact-search {
        padding: 0.6rem 0.8rem;
    }
    
    .text-box {
        padding: 0.45rem 0.6rem;
        gap: 0.35rem;
    }
    
    .text-box .left-actions span {
        width: 30px;
        height: 30px;
        font-size: 19px;
    }
    
    .text-box .send-message {
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
    }
    
    .text-box .send-message .send-icon {
        width: 24px;
        height: 24px;
    }
    
    .text-box .donate-btn {
        width: 30px;
        height: 30px;
        font-size: 19px;
    }
}

/* Mobile Optimizations */
@media (max-width: 576px) {
    /* Header adjustments for mobile */
    .chat-window-header {
        height: 54px;
        padding: 0 0.5rem;
        gap: 0.5rem;
    }
    
    .header-back-btn,
    .header-action-btn,
    .header-close-btn {
        width: 32px;
        height: 32px;
        font-size: 15px;
    }
    
    .header-close-btn {
        font-size: 16px;
    }
    
    .header-back-btn {
        font-size: 15px;
    }
    
    .header-avatar {
        width: 34px;
        height: 34px;
    }
    
    .header-contact-info {
        gap: 0.5rem;
        padding: 0.375rem;
        margin: -0.375rem;
    }
    
    .header-username {
        font-size: 14px;
    }
    
    .header-status-text {
        font-size: 11px;
    }
    
    .archived-footer-content {
        padding: 0.45rem 0.55rem;
        gap: 0.3rem;
    }
    
    .archived-message {
        font-size: 12px;
        gap: 0.35rem;
    }
    
    .archived-message i {
        font-size: 14px;
    }
    
    .archived-footer-content .donate-btn {
        width: 28px;
        height: 28px;
        font-size: 18px;
        margin-left: 0.05rem;
    }
    
    /* Telegram input adjustments for mobile */
    .contact-search {
        padding: 0.5rem;
    }
    
    .text-box {
        padding: 0.45rem 0.55rem;
        gap: 0.35rem;
    }
    
    .text-box .message-input {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }
    
    .text-box .left-actions span {
        width: 30px;
        height: 30px;
        font-size: 19px;
    }
    
    .text-box .send-message {
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
    }
    
    .text-box .send-message .send-icon {
        width: 24px;
        height: 24px;
    }
    
    .text-box .donate-btn {
        width: 30px;
        height: 30px;
        font-size: 19px;
    }
}

/* ==================== TELEGRAM-INSPIRED DESIGN ==================== */
/* 
   Telegram-style chat bubbles - clean, geometric, information-dense
   
   KEY DIFFERENCES FROM FACEBOOK:
   - Asymmetric corners (tail effect)
   - No shadows (flat design)
   - Inline metadata (time + status on same line)
   - More compact spacing
   - Squared-off aesthetic
   - Minimalist approach
   
   HOW TO ENABLE:
   Add class "chat-telegram" to .chat-message-container
   Example: <div class="chat-message-container active chat-telegram">
*/

/* -------------------- Telegram Message Containers -------------------- */

.chat-telegram .receiving-message-container,
.chat-telegram .sending-message-container {
    padding: 1px 8px; /* Compact Telegram style - just 8px on sides */
    padding-right: 32px; /* Extra space for heart icon on the right */
    margin-bottom: 0;
    display: flex; /* Enable flexbox for avatar layout */
    align-items: flex-end; /* Align avatar to bottom */
    gap: 8px; /* Space between avatar and bubble */
    position: relative; /* For positioning quick reactions bar */
}

/* Sent messages don't need flex (no avatar) */
.chat-telegram .sending-message-container {
    justify-content: flex-end;
}

/* -------------------- Telegram-Style Avatar -------------------- */

.chat-telegram .message-avatar {
    width: 34px;
    height: 34px;
    flex-shrink: 0; /* Don't allow avatar to shrink */
    border-radius: 50%;
    overflow: hidden;
    background: var(--accent-gradient-2); /* Brand color background */
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end; /* Avatar at bottom, aligned with tail */
    margin-bottom: 4px; /* Slight spacing from bottom */
}

.chat-telegram .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Avatar placeholder (first letter) when no avatar image */
.chat-telegram .avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--static-1);
    text-transform: uppercase;
}

/* Hide avatar by default for sent messages (remove from layout) */
.chat-telegram .sending-message-container .message-avatar {
    display: none; /* Sending messages don't need avatar space */
}

/* For received messages: Always reserve space, but hide avatar (Facebook Messenger style) */
.chat-telegram .receiving-message-container .message-avatar {
    display: flex; /* Always in layout - reserves space */
    visibility: hidden; /* Hidden by default */
}

/* Show avatar ONLY on the last message in a group */
.chat-telegram .receiving-message-container:not(:has(+ .receiving-message-container)) .message-avatar {
    visibility: visible; /* Make visible for last message */
}

/* Add spacing only between different message groups */
.chat-telegram .receiving-message-container.new-group,
.chat-telegram .sending-message-container.new-group {
    margin-top: 8px;
}

/* -------------------- Telegram Received Messages -------------------- */

.chat-telegram .receiving-message {
    max-width: 320px; /* Compact Telegram width */
    padding: 8px 12px 6px 12px; /* Compact padding */
    position: relative; /* For absolute positioning of tail and reply button */
    
    /* Telegram signature: rounded on 3 corners, sharp on bottom-left (tail) */
    border-radius: 12px 12px 12px 2px;
    
    background: #363b4e; /* Better contrast - more distinct from background */
    border: none; /* Clean, no borders */
    box-shadow: none; /* Flat design - no shadows */
    
    transition: background 0.1s ease; /* Fast transitions */
}

/* Comic book style tail - pointing to avatar (left side) */
.chat-telegram .receiving-message::before {
    content: '';
    position: absolute;
    left: -8px;
    bottom: 8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-right-color: #363b4e;
    border-left: 0;
    border-bottom: 0;
    transform: translateY(4px);
}

.chat-telegram .receiving-message:hover {
    background: #3f4558; /* Subtle highlight */
}

.chat-telegram .receiving-message:hover::before {
    border-right-color: #3f4558; /* Match hover background */
}

/* Username - block element (own line) */
.chat-telegram .receiving-message .name {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 2px;
    text-transform: none;
    color: #6fb1ff; /* Brighter blue for better readability */
    letter-spacing: normal;
}

/* Message text - compact */
.chat-telegram .receiving-message .message {
    display: block;
    font-size: 14px;
    line-height: 1.35; /* Tighter than Facebook */
    font-family: var(--font-family-2) !important;
    color: var(--color-text-1);
    white-space: pre-line; /* Preserve line breaks but collapse spaces */
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin: 0;
    padding: 0;
    text-indent: 0;
    overflow: hidden; /* Prevent float from affecting text layout */
}

/* Timestamp - INLINE at bottom-right (Telegram style) */
.chat-telegram .receiving-message .time {
    display: block;
    float: right;
    font-size: 11px;
    font-weight: 400;
    margin-left: 8px;
    margin-top: 2px;
    text-transform: none;
    color: var(--color-dark-5);
    letter-spacing: normal;
    opacity: 0.7; /* Always visible but subtle */
}

/* -------------------- Telegram Sent Messages -------------------- */

.chat-telegram .sending-message {
    max-width: 320px; /* Compact Telegram width */
    padding: 8px 12px 6px 12px;
    position: relative; /* For absolute positioning of tail and heart icon */
    
    /* Telegram signature: rounded on 3 corners, sharp on bottom-right (tail) */
    border-radius: 12px 12px 2px 12px;
    
    background: linear-gradient(135deg, #2a6cba 0%, #1c5ba8 100%); /* Flatter gradient */
    border: none;
    box-shadow: none; /* Flat design */
    
    transition: background 0.1s ease;
}

/* Comic book style tail - pointing right (outward from user) */
.chat-telegram .sending-message::before {
    content: '';
    position: absolute;
    right: -8px;
    bottom: 8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-left-color: #1c5ba8; /* Match darker gradient color */
    border-right: 0;
    border-bottom: 0;
    transform: translateY(4px);
}

.chat-telegram .sending-message:hover {
    background: linear-gradient(135deg, #3078c7 0%, #2260b0 100%); /* Slightly brighter */
}

.chat-telegram .sending-message:hover::before {
    border-left-color: #2260b0; /* Match hover gradient */
}

/* Hide username for sent messages */
.chat-telegram .sending-message .name {
    display: none;
}

/* Message text */
.chat-telegram .sending-message .message {
    display: block;
    font-size: 14px;
    line-height: 1.35;
    font-family: var(--font-family-2), serif !important;
    color: var(--static-1);
    white-space: pre-line; /* Preserve line breaks but collapse spaces */
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin: 0;
    padding: 0;
    text-indent: 0;
    overflow: hidden; /* Prevent float from affecting text layout */
}

/* Timestamp with read receipt - INLINE (Telegram style) */
.chat-telegram .sending-message .time {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    float: right;
    font-size: 11px;
    font-weight: 400;
    margin-left: 8px;
    margin-top: 2px;
    text-align: right;
    text-transform: none;
    color: rgba(255, 255, 255, 0.75);
    letter-spacing: normal;
    opacity: 1; /* Always visible */
}

/* -------------------- Consecutive Message Grouping -------------------- */

/* Hide name for consecutive messages from same user */
.chat-telegram .receiving-message-container + .receiving-message-container .receiving-message .name {
    display: none;
}

/* Comfortable spacing for consecutive messages - slightly more breathing room than Telegram */
.chat-telegram .receiving-message-container + .receiving-message-container {
    padding-top: 10px;
}

.chat-telegram .sending-message-container + .sending-message-container {
    padding-top: 10px;
}

/* Change tail position for middle messages in a group */
.chat-telegram .receiving-message-container + .receiving-message-container .receiving-message {
    border-radius: 12px 12px 12px 12px; /* All rounded for middle messages */
}

/* Hide comic book tail for consecutive (middle) messages */
.chat-telegram .receiving-message-container + .receiving-message-container .receiving-message::before {
    display: none;
}

.chat-telegram .sending-message-container + .sending-message-container .sending-message {
    border-radius: 12px 12px 12px 12px; /* All rounded for middle messages */
}

/* Hide comic book tail for consecutive (middle) messages */
.chat-telegram .sending-message-container + .sending-message-container .sending-message::before {
    display: none;
}

/* Last message in group gets the tail */
.chat-telegram .receiving-message-container:not(:has(+ .receiving-message-container)) .receiving-message {
    border-radius: 12px 12px 12px 2px !important; /* Bottom-left tail */
}

.chat-telegram .sending-message-container:not(:has(+ .sending-message-container)) .sending-message {
    border-radius: 12px 12px 2px 12px !important; /* Bottom-right tail */
}

/* ==================== DATE SEPARATORS (Telegram-style) ==================== */

/* Fade-in animation for new separators */
@keyframes dateSeparatorFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-date-separator {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 12px 0;
    padding: 0 16px;
    width: 100%;
    clear: both;
    user-select: none;
    animation: dateSeparatorFadeIn 0.3s ease-out;
}

.date-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    background-color: var(--color-dark-2);
    color: var(--color-text-2);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    text-align: center;
    white-space: nowrap;
}

/* Dark theme adjustments */
[data-theme="dark"] .date-badge {
    background-color: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Light theme adjustments */
[data-theme="light"] .date-badge {
    background-color: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.5);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Spacing adjustment - more space after date separator */
.chat-date-separator + .receiving-message-container,
.chat-date-separator + .sending-message-container {
    margin-top: 8px;
}

/* -------------------- Message Actions - REMOVED (Now using context menu) -------------------- */
/* Old inline reply/edit/delete buttons removed in favor of right-click context menu */

/* ==================== TELEGRAM-STYLE CONTEXT MENU ==================== */

.chat-context-menu {
    position: fixed;
    z-index: 10000;
    background: #2e3341;
    border: 1px solid #3f4558;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    padding: 6px 0;
    min-width: 220px;
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.chat-context-menu.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
}

.chat-context-menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 18px;
    cursor: pointer;
    transition: background-color 0.12s ease;
    user-select: none;
    color: #e4e6eb;
}

.chat-context-menu-item:hover {
    background-color: #4a9eff;
    color: #ffffff;
}

.chat-context-menu-item i {
    width: 20px;
    font-size: 15px;
    text-align: center;
    opacity: 0.9;
}

.chat-context-menu-item:hover i {
    opacity: 1;
}

.chat-context-menu-item-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.chat-context-menu-divider {
    height: 1px;
    background: #3f4558;
    margin: 6px 8px;
}

/* ==================== TELEGRAM-STYLE REACTION BUBBLE (SEPARATE POPUP) ==================== */

.chat-context-reactions-bubble {
    position: fixed;
    z-index: 10001; /* Above context menu */
    background: var(--bg-color-3);
    border: 1px solid var(--bg-color-6);
    border-radius: 28px; /* Pill shape like Telegram */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: 6px 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transform: scale(0.9) translateY(10px);
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); /* Bouncy animation */
}

.chat-context-reactions-bubble.active {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

.chat-context-reaction-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.15s ease;
    user-select: none;
    font-size: 26px;
}

.chat-context-reaction-btn:hover {
    background-color: rgba(74, 158, 255, 0.15);
    transform: scale(1.25);
}

.chat-context-reaction-btn:active {
    transform: scale(1.1);
}

/* Twemoji support in reaction bubble */
.chat-context-reaction-btn img.emoji {
    width: 26px !important;
    height: 26px !important;
    margin: 0 !important;
}

/* Light theme support */
[data-theme="light"] .chat-context-reactions-bubble {
    background: #ffffff;
    border-color: #e4e4e7;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .chat-context-reaction-btn:hover {
    background-color: rgba(74, 158, 255, 0.08);
}

.chat-context-menu-item.danger {
    color: #ff6b6b;
}

.chat-context-menu-item.danger:hover {
    background-color: #e74c3c;
    color: #ffffff;
}

/* Light theme adjustments */
[data-theme="light"] .chat-context-menu {
    background: #ffffff;
    border-color: #d1d5db;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .chat-context-menu-item {
    color: #1f2937;
}

[data-theme="light"] .chat-context-menu-item:hover {
    background-color: #4a9eff;
    color: #ffffff;
}

[data-theme="light"] .chat-context-menu-divider {
    background: #e5e7eb;
}

[data-theme="light"] .chat-context-menu-item.danger {
    color: #dc2626;
}

[data-theme="light"] .chat-context-menu-item.danger:hover {
    background-color: #ef4444;
    color: #ffffff;
}

/* Mobile context menu adjustments */
@media (max-width: 768px) {
    .chat-context-menu {
        min-width: 200px;
        max-width: 90vw; /* Don't overflow screen */
        border-radius: 16px; /* More rounded for mobile */
        padding: 10px 0;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); /* Stronger shadow */
    }
    
    .chat-context-menu-item {
        padding: 16px 20px; /* Even larger touch targets */
        gap: 18px;
        min-height: 50px; /* Ensure minimum height for easy tapping */
    }
    
    .chat-context-menu-item i {
        font-size: 18px; /* Bigger icons */
        width: 24px;
    }
    
    .chat-context-menu-item-text {
        font-size: 16px; /* Bigger text */
        font-weight: 500;
    }
    
    .chat-context-menu-divider {
        margin: 8px 12px; /* More spacing */
    }
    
    /* Reaction bubble adjustments for mobile */
    .chat-context-reactions-bubble {
        padding: 10px 12px;
        gap: 8px;
        border-radius: 36px; /* More rounded */
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); /* Stronger shadow to stand out */
    }
    
    .chat-context-reaction-btn {
        width: 48px; /* Bigger buttons */
        height: 48px;
        font-size: 30px; /* Bigger emojis */
    }
    
    .chat-context-reaction-btn:hover {
        transform: scale(1.15); /* Less aggressive scale on mobile */
    }
    
    .chat-context-reaction-btn img.emoji {
        width: 30px !important;
        height: 30px !important;
    }
    
    /* Bottom sheet style positioning for mobile */
    .chat-context-menu {
        /* Position near bottom for easier thumb reach */
        bottom: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: calc(100vw - 40px); /* Full width with margins */
        max-width: 400px;
    }
    
    .chat-context-menu.active {
        transform: translateX(-50%) scale(1) !important;
    }
}

/* Highlight message on right-click */
.chat-telegram .receiving-message.context-active,
.chat-telegram .sending-message.context-active {
    background-color: rgba(74, 158, 255, 0.15);
}

/* ==================== TELEGRAM-STYLE EDIT BANNER ==================== */

.telegram-edit-banner {
    display: flex;
    align-items: stretch;
    background: #3a3f52;
    border-radius: 8px;
    margin: 0 12px 10px 12px;
    overflow: hidden;
    animation: editBannerSlideIn 0.2s ease-out;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

@keyframes editBannerSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Left accent bar (Orange/amber for edit) */
.edit-banner-accent {
    width: 3px;
    background: #ff9500;
    flex-shrink: 0;
}

/* Content area */
.edit-banner-content {
    flex: 1;
    padding: 10px 14px;
    min-width: 0;
}

.edit-banner-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.edit-banner-icon {
    font-size: 12px;
    color: #ff9500;
}

.edit-banner-title {
    font-size: 13px;
    font-weight: 700;
    color: #ff9500;
}

.edit-banner-preview {
    font-size: 13px;
    color: #c8ccd4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

/* Close button */
.edit-banner-close {
    background: none;
    border: none;
    color: #9ba0ab;
    cursor: pointer;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-size: 16px;
}

.edit-banner-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e8eaf0;
}

.edit-banner-close:active {
    transform: scale(0.95);
}

/* Light theme */
[data-theme="light"] .telegram-edit-banner {
    background: #fff5e6;
    border: 1px solid #ffd699;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .edit-banner-accent {
    background: #ff9500;
}

[data-theme="light"] .edit-banner-icon {
    color: #ff8800;
}

[data-theme="light"] .edit-banner-title {
    color: #ff8800;
}

[data-theme="light"] .edit-banner-preview {
    color: #5f6368;
}

[data-theme="light"] .edit-banner-close {
    color: #70757a;
}

[data-theme="light"] .edit-banner-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #202124;
}

/* ==================== TELEGRAM-STYLE REPLY BANNER ==================== */

.telegram-reply-banner {
    display: flex;
    align-items: stretch;
    background: #363b4e;
    border-radius: 8px;
    margin: 0 12px 10px 12px;
    overflow: hidden;
    animation: replyBannerSlideIn 0.2s ease-out;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

@keyframes replyBannerSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Left accent bar (Telegram blue) */
.reply-banner-accent {
    width: 3px;
    background: #5b9fff;
    flex-shrink: 0;
}

/* Image thumbnail (Telegram-style) */
.reply-banner-thumbnail {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    margin: 8px 0 8px 10px;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
}

.reply-banner-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Adjust content padding when thumbnail is present */
.telegram-reply-banner.has-thumbnail .reply-banner-content {
    padding-left: 10px;
}

/* Content area */
.reply-banner-content {
    flex: 1;
    padding: 10px 14px;
    min-width: 0;
}

.reply-banner-username {
    font-size: 13px;
    font-weight: 700;
    color: #6fb1ff;
    margin-bottom: 4px;
}

.reply-banner-preview {
    font-size: 13px;
    color: #c8ccd4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

/* Close button */
.reply-banner-close {
    background: none;
    border: none;
    color: #9ba0ab;
    cursor: pointer;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-size: 16px;
}

.reply-banner-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e8eaf0;
}

.reply-banner-close:active {
    transform: scale(0.95);
}

/* Light theme */
[data-theme="light"] .telegram-reply-banner {
    background: #f7f9fc;
    border: 1px solid #e4e8f0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .reply-banner-accent {
    background: #4a9eff;
}

[data-theme="light"] .reply-banner-username {
    color: #0a7fcc;
    font-weight: 700;
}

[data-theme="light"] .reply-banner-preview {
    color: #5f6368;
}

[data-theme="light"] .reply-banner-close {
    color: #70757a;
}

[data-theme="light"] .reply-banner-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #202124;
}

[data-theme="light"] .reply-banner-thumbnail {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .telegram-reply-banner {
        margin: 0 8px 8px 8px;
    }
    
    .reply-banner-content {
        padding: 8px 12px;
    }
    
    .reply-banner-close {
        padding: 0 12px;
    }
}

/* -------------------- Reply Preview Inside Messages -------------------- */

.chat-telegram .reply-preview {
    background: rgba(91, 159, 255, 0.15) !important;
    border-left: 3px solid #5b9fff !important;
    padding: 6px 10px !important;
    margin-bottom: 6px !important;
    border-radius: 6px !important;
    cursor: pointer;
    transition: background 0.15s ease;
    display: flex !important;
    align-items: center;
    gap: 8px;
}

.chat-telegram .reply-preview:hover {
    background: rgba(91, 159, 255, 0.25) !important;
}

/* Image thumbnail in message reply preview */
.chat-telegram .reply-preview-thumbnail {
    width: 32px;
    height: 32px;
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.2);
}

.chat-telegram .reply-preview-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Content wrapper for text */
.chat-telegram .reply-preview-content {
    flex: 1;
    min-width: 0; /* Important for text-overflow to work in flexbox */
    overflow: hidden; /* Ensure overflow is hidden */
}

.chat-telegram .reply-preview > div:first-child,
.chat-telegram .reply-preview-content > div:first-child {
    font-size: 12px !important;
    color: #6fb1ff !important;
    font-weight: 600 !important;
    margin-bottom: 3px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-telegram .reply-preview > div:last-child,
.chat-telegram .reply-preview-content > div:last-child {
    font-size: 13px !important;
    color: #d4d7dd !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-height: 40px; /* Allow up to 2 lines */
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Show max 2 lines */
    -webkit-box-orient: vertical;
    white-space: normal; /* Allow wrapping for multi-line */
    word-break: break-word;
}

/* Light theme - Reply Preview */
[data-theme="light"] .chat-telegram .reply-preview {
    background: rgba(0, 0, 0, 0.04) !important;
    border-left-color: #0088cc !important;
}

[data-theme="light"] .chat-telegram .reply-preview:hover {
    background: rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .chat-telegram .reply-preview-thumbnail {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .chat-telegram .reply-preview > div:first-child,
[data-theme="light"] .chat-telegram .reply-preview-content > div:first-child {
    color: #0a7fcc !important;
    font-weight: 700 !important;
}

[data-theme="light"] .chat-telegram .reply-preview > div:last-child,
[data-theme="light"] .chat-telegram .reply-preview-content > div:last-child {
    color: #000000 !important;
    opacity: 0.7;
}

/* ==================== TWEMOJI - Telegram-Style Emoji Rendering ==================== */

/* Base Twemoji styling - consistent rendering across all platforms */
img.chat-emoji {
    display: inline-block;
    height: 1.2em; /* Relative to text size */
    width: 1.2em;
    margin: 0 0.05em 0 0.1em;
    vertical-align: -0.2em; /* Align with text baseline */
    image-rendering: -webkit-optimize-contrast; /* Better rendering on WebKit */
    image-rendering: crisp-edges; /* Better rendering on other browsers */
}

/* Twemoji in messages */
.chat-telegram .message img.chat-emoji {
    height: 1.3em;
    width: 1.3em;
}

/* Twemoji in reactions - slightly larger */
.chat-telegram .reaction-emoji img.chat-emoji {
    height: 18px;
    width: 18px;
    margin: 0;
    vertical-align: middle;
}

/* Twemoji in emoji picker - larger for easy clicking */
.emoji-picker img.chat-emoji {
    height: 24px;
    width: 24px;
    margin: 0;
    vertical-align: middle;
}

/* Hide native emoji text when Twemoji image is present */
.emoji-grid span:has(img.chat-emoji) {
    font-size: 0; /* Hide text node */
}

.emoji-grid span img.chat-emoji {
    font-size: 24px; /* Restore size for image */
}

/* Twemoji in quick reactions bar (to be implemented) */
.quick-reactions img.chat-emoji {
    height: 20px;
    width: 20px;
    margin: 0;
    vertical-align: middle;
}

/* Large emoji for single-emoji messages (Telegram feature) */
.chat-telegram .message-single-emoji img.chat-emoji {
    height: 3em;
    width: 3em;
    margin: 0.2em;
}

/* Prevent emoji from breaking layout */
img.chat-emoji {
    flex-shrink: 0;
    user-select: auto; /* Allow selecting emojis in messages */
    -webkit-user-drag: none;
}

/* But disable selection in inputs/pickers where it's not needed */
.text-box .message-input img.chat-emoji,
.emoji-picker img.chat-emoji,
.telegram-emoji-popup img.chat-emoji,
.telegram-reaction-heart img.chat-emoji {
    user-select: none;
}

/* ==================== REACTION PICKER MODAL - Telegram Style ==================== */

.reaction-picker-popup {
    /* Positioned absolutely in JS */
    position: fixed;
    z-index: 10000;
    background: var(--bg-color-3);
    border: 1px solid var(--bg-color-6);
    border-radius: 22px; /* More rounded like Telegram pill */
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    padding: 6px; /* Reduced padding for compactness */
    width: 50px; /* Telegram-style narrow vertical column */
    max-height: 280px; /* Taller but scrollable */
    overflow: hidden; /* Container doesn't scroll, only grid inside */
    animation: reactionPickerSlideIn 0.2s ease-out;
}

@keyframes reactionPickerSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.reaction-picker-grid {
    display: flex;
    flex-direction: column; /* Vertical column like Telegram */
    gap: 2px;
    padding: 0;
    max-height: 268px; /* Slightly less than container */
    overflow-x: hidden;
    overflow-y: auto; /* Scrollable content */
    scrollbar-width: none; /* Hide scrollbar for clean look */
    -ms-overflow-style: none; /* IE and Edge */
}

.reaction-picker-grid::-webkit-scrollbar {
    display: none; /* Hide scrollbar Chrome/Safari */
}

.emoji-reaction {
    cursor: pointer;
    padding: 6px;
    border-radius: 50%; /* Circular buttons like Telegram */
    transition: all 0.15s ease;
    text-align: center;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px; /* Larger emojis in vertical layout */
    width: 38px;
    height: 38px;
    flex-shrink: 0;
}

.emoji-reaction:hover {
    background: var(--bg-color-4);
    transform: scale(1.15);
}

.emoji-reaction:active {
    transform: scale(1.05);
}

/* Twemoji in reaction picker */
.emoji-reaction img.chat-emoji {
    width: 28px !important;
    height: 28px !important;
    margin: 0;
}

/* Mobile responsive */
@media (max-width: 576px) {
    .reaction-picker-popup {
        width: 50px; /* Keep vertical column on mobile */
        max-height: 240px; /* Slightly shorter on mobile */
    }
    
    .reaction-picker-grid {
        max-height: 228px;
    }
    
    .emoji-reaction {
        padding: 5px;
        font-size: 26px;
        width: 36px;
        height: 36px;
    }
    
    .emoji-reaction img.chat-emoji {
        width: 26px !important;
        height: 26px !important;
    }
}

/* Light theme support */
html[data-theme='light'] .reaction-picker-popup {
    background: #ffffff;
    border-color: #e4e4e7;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

html[data-theme='light'] .emoji-reaction:hover {
    background: rgba(74, 158, 255, 0.08);
}

/* -------------------- Telegram Heart Icon (Reaction Trigger) -------------------- */

.telegram-reaction-heart {
    position: absolute;
    bottom: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    font-size: 18px; /* Emoji size */
    transition: opacity 0.2s ease, transform 0.15s ease;
    z-index: 10;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
    /* Prevent rendering issues on different screens */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    will-change: transform, opacity;
    /* Prevent emoji distortion */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Twemoji styling for heart icon */
.telegram-reaction-heart img.chat-emoji {
    width: 22px !important; /* Increased from 20px to better fill container */
    height: 22px !important;
    margin: 0;
    /* Ensure sharp rendering */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    /* Prevent distortion */
    object-fit: contain;
    display: block;
}

/* For SENT messages (your messages) - heart on LEFT */
.sending-message-container .telegram-reaction-heart {
    left: -28px; /* Close to the message bubble */
    right: auto;
}

/* For RECEIVED messages (their messages) - heart on RIGHT */
.receiving-message-container .telegram-reaction-heart {
    right: -28px; /* Close to the message bubble */
    left: auto;
}

/* Show on message hover */
.sending-message-container:hover .telegram-reaction-heart,
.receiving-message-container:hover .telegram-reaction-heart {
    opacity: 1;
}

/* DISABLE reactions on archived/read-only chats */
.chat-message-container[data-read-only="true"] .telegram-reaction-heart {
    display: none !important;
    pointer-events: none !important;
}

.chat-message-container[data-read-only="true"] .sending-message-container:hover .telegram-reaction-heart,
.chat-message-container[data-read-only="true"] .receiving-message-container:hover .telegram-reaction-heart {
    opacity: 0 !important;
    display: none !important;
}

.chat-message-container[data-read-only="true"] .telegram-emoji-popup {
    display: none !important;
}

/* DISABLE right-click context menu on archived/read-only chats */
.chat-message-container[data-read-only="true"] .receiving-message,
.chat-message-container[data-read-only="true"] .sending-message {
    pointer-events: none !important;
}

/* Allow text selection but prevent context menu */
.chat-message-container[data-read-only="true"] .telegram-message-text {
    pointer-events: auto;
    user-select: text;
}

/* Hide context menu when shown for archived chat messages */
.chat-message-container[data-read-only="true"] ~ .chat-context-menu {
    display: none !important;
}

/* DISABLE reactions on small screens (mobile/tablet) */
@media (max-width: 768px) {
    .telegram-reaction-heart {
        display: none !important;
        pointer-events: none !important;
    }
    
    .sending-message-container:hover .telegram-reaction-heart,
    .receiving-message-container:hover .telegram-reaction-heart {
        opacity: 0 !important;
        display: none !important;
    }
    
    .telegram-emoji-popup {
        display: none !important;
    }
}

.telegram-reaction-heart:hover {
    transform: scale(1.15); /* Slightly reduced to prevent distortion */
    /* Ensure sharp rendering on scale */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Prevent blurry scaling */
    transform-origin: center;
}

/* Remove old light theme color override */

/* -------------------- Telegram Emoji Popup (Minimalistic Vertical Column) -------------------- */

.telegram-emoji-popup {
    position: fixed; /* Fixed positioning to prevent scroll issues */
    z-index: 10000; /* High z-index to appear above everything */
    width: 40px !important; /* Even more compact */
    max-height: 180px !important; /* Shorter for better control */
    background: var(--bg-color-3);
    border: 1px solid var(--bg-color-6);
    border-radius: 20px; /* Very rounded pill shape */
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    padding: 3px;
    animation: telegramEmojiPopupSlideIn 0.2s ease-out;
    overflow: hidden; /* Container doesn't scroll */
    pointer-events: auto; /* Ensure popup can be interacted with */
}

/* Flipped down when near top of chat - positioning now handled in JS */
.telegram-emoji-popup.flipped-down {
    /* Positioning handled by JS with fixed positioning */
}

/* For SENT messages (your messages) - positioning now handled in JS */
.sending-message-container .telegram-emoji-popup {
    /* Positioning handled by JS with fixed positioning */
}

/* For RECEIVED messages (their messages) - positioning now handled in JS */
.receiving-message-container .telegram-emoji-popup {
    /* Positioning handled by JS with fixed positioning */
}

@keyframes telegramEmojiPopupSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Minimalistic vertical scrollable emoji column (like Telegram) */
.telegram-emoji-grid {
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none; /* Hide scrollbar for clean look */
    -ms-overflow-style: none; /* IE and Edge */
    padding: 0;
    max-height: 174px; /* Slightly less than container for padding */
    position: relative;
    /* Telegram-style fade effect at top and bottom */
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        black 12px,
        black calc(100% - 12px),
        transparent 100%
    );
    mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        black 12px,
        black calc(100% - 12px),
        transparent 100%
    );
}

.telegram-emoji-grid::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome, Safari and Opera */
}

/* Emoji buttons in vertical column popup (compact and small) */
.telegram-emoji-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 22px; /* Smaller emojis */
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.15s ease;
    width: 32px; /* Smaller buttons */
    height: 32px;
    flex-shrink: 0; /* Prevent squishing */
}

.telegram-emoji-btn:hover {
    background: rgba(74, 158, 255, 0.15);
    transform: scale(1.1);
}

.telegram-emoji-btn:active {
    transform: scale(1);
}

/* Twemoji in vertical column popup (smaller) */
.telegram-emoji-btn img.chat-emoji {
    width: 22px !important;
    height: 22px !important;
}

/* Light theme - minimalistic popup */
html[data-theme='light'] .telegram-emoji-popup {
    background: #ffffff;
    border-color: #e4e4e7;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

html[data-theme='light'] .telegram-emoji-btn:hover {
    background: rgba(74, 158, 255, 0.08);
}

/* -------------------- Reactions - Compact Pills -------------------- */

.chat-telegram .reactions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    clear: both;
}

.chat-telegram .reaction-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 16px;
    background: rgba(74, 158, 255, 0.08);
    border: 1px solid rgba(74, 158, 255, 0.2);
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 26px;
}

.chat-telegram .reaction-item:hover {
    background: rgba(74, 158, 255, 0.18);
    border-color: rgba(74, 158, 255, 0.4);
    transform: translateY(-1px);
}

.chat-telegram .reaction-item:active {
    transform: scale(0.95);
}

/* Read-only reactions (archived chats) */
.chat-message-container[data-archived="true"] .reaction-item {
    cursor: default;
    opacity: 0.7;
}

.chat-message-container[data-archived="true"] .reaction-item:hover {
    background: rgba(74, 158, 255, 0.08);
    border-color: rgba(74, 158, 255, 0.2);
    transform: none;
}

.chat-telegram .reaction-emoji {
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
}

/* Twemoji in reactions display */
.chat-telegram .reaction-emoji img.chat-emoji {
    width: 16px !important;
    height: 16px !important;
}

.chat-telegram .reaction-count {
    font-size: 12px;
    font-weight: 600;
    color: #4a9eff;
    min-width: 12px;
    text-align: center;
}

/* Light theme adjustments */
html[data-theme='light'] .chat-telegram .reaction-item {
    background: rgba(74, 158, 255, 0.06);
    border-color: rgba(74, 158, 255, 0.15);
}

html[data-theme='light'] .chat-telegram .reaction-item:hover {
    background: rgba(74, 158, 255, 0.12);
    border-color: rgba(74, 158, 255, 0.3);
}

html[data-theme='light'] .chat-telegram .reaction-count {
    color: #0a7fcc;
}

/* -------------------- Read Receipts - Telegram Check Marks -------------------- */

.chat-telegram .read-receipt {
    display: inline-flex;
    align-items: center;
    line-height: 1;
    margin-left: 3px;
    vertical-align: middle;
    position: relative;
}

/* Single checkmark - sent but not read yet (gray) */
.chat-telegram .read-receipt-sent i {
    font-size: 12px;
    font-weight: 400; /* Thinner - normal weight instead of 600 */
    color: rgba(255, 255, 255, 0.45); /* Subtle gray for sent messages */
}

/* Double checkmark - read (Telegram blue) with side-by-side overlap */
.chat-telegram .read-receipt-read {
    letter-spacing: -4px; /* Overlap the two checkmarks */
}

.chat-telegram .read-receipt-read i {
    font-size: 12px;
    font-weight: 400; /* Thinner - normal weight instead of 600 */
    color: #4fc3f7; /* Telegram's exact read checkmark blue */
    position: relative;
}

/* Second checkmark is slightly offset to create the Telegram effect */
.chat-telegram .read-receipt-read i:last-child {
    margin-left: -4px;
}

/* Smooth transition when converting from single to double */
.chat-telegram .read-receipt i {
    transition: color 0.2s ease, transform 0.1s ease;
}

/* Make checkmarks align perfectly with timestamp */
.chat-telegram .sending-message .time {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* -------------------- Typing Indicator - Discord Style -------------------- */

.discord-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    margin: 2px 8px 2px 50px; /* Align with received messages (after avatar space) */
    animation: typingFadeIn 0.3s ease-out;
}

@keyframes typingFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.typing-avatar-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: rgba(74, 158, 255, 0.15);
    border-radius: 50%;
    flex-shrink: 0;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 3px;
}

.typing-dots span {
    width: 5px;
    height: 5px;
    background: #4a9eff;
    border-radius: 50%;
    animation: discordTypingDot 1.4s infinite ease-in-out;
}

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

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

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

@keyframes discordTypingDot {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.typing-text {
    font-size: 13px;
    color: var(--color-text-2);
    line-height: 1.3;
}

.typing-text strong {
    color: var(--color-text-1);
    font-weight: 600;
}

/* Light theme adjustments */
html[data-theme='light'] .typing-avatar-dots {
    background: rgba(74, 158, 255, 0.1);
}

html[data-theme='light'] .typing-dots span {
    background: #0a7fcc;
}

html[data-theme='light'] .typing-text {
    color: #71717a;
}

html[data-theme='light'] .typing-text strong {
    color: #27272a;
}

/* Old Telegram-style typing indicator (kept for backward compatibility) */
.chat-telegram .typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 8px 12px;
    background: #363b4e;
    border-radius: 12px 12px 12px 2px;
    box-shadow: none;
}

.chat-telegram .typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--color-dark-5);
    border-radius: 50%;
    animation: telegramTyping 1.2s infinite ease-in-out;
}

.chat-telegram .typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.chat-telegram .typing-indicator span:nth-child(2) {
    animation-delay: 0.15s;
}

.chat-telegram .typing-indicator span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes telegramTyping {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.3);
        opacity: 1;
    }
}

/* -------------------- Telegram-Style Animations -------------------- */

/* Fast, snappy animations - Telegram is known for speed */
@keyframes telegramSlideIn {
    from {
        opacity: 0;
        transform: translateY(5px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-telegram .receiving-message-container,
.chat-telegram .sending-message-container {
    animation: telegramSlideIn 0.15s ease-out; /* Faster than Facebook */
}

/* -------------------- Selection Highlight -------------------- */

/* Telegram has a distinctive selection highlight */
.chat-telegram .receiving-message::selection,
.chat-telegram .sending-message::selection {
    background: rgba(74, 158, 255, 0.3);
}

/* -------------------- Mobile Responsive -------------------- */

@media (max-width: 768px) {
    .chat-telegram .receiving-message,
    .chat-telegram .sending-message {
        max-width: 280px;
    }
}

@media (max-width: 576px) {
    .chat-telegram .receiving-message,
    .chat-telegram .sending-message {
        max-width: 240px;
    }
    
    .chat-telegram .receiving-message .message,
    .chat-telegram .sending-message .message {
        font-size: 13px;
    }
}

/* -------------------- Dark/Light Mode Optimization -------------------- */

/* Telegram has excellent contrast in both modes */
html[data-theme='light'] .chat-telegram .receiving-message {
    background: #ffffff; /* Pure white for better contrast */
    color: #000;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); /* Subtle shadow for definition */
}

html[data-theme='light'] .chat-telegram .receiving-message::before {
    border-right-color: #ffffff; /* Match light theme background */
}

html[data-theme='light'] .chat-telegram .receiving-message:hover {
    background: #f8f9fa;
}

html[data-theme='light'] .chat-telegram .receiving-message:hover::before {
    border-right-color: #f8f9fa; /* Match hover background */
}

html[data-theme='light'] .chat-telegram .receiving-message .time {
    color: #6c757d;
}

html[data-theme='light'] .chat-telegram .receiving-message .name {
    color: #0a7fcc;
    font-weight: 700;
}

/* Light theme - Sending messages */
html[data-theme='light'] .chat-telegram .sending-message {
    background: linear-gradient(135deg, #4da3ff 0%, #2b8fe0 100%);
    color: #ffffff;
}

html[data-theme='light'] .chat-telegram .sending-message::before {
    border-left-color: #2b8fe0; /* Match light theme gradient */
}

html[data-theme='light'] .chat-telegram .sending-message:hover {
    background: linear-gradient(135deg, #5cafff 0%, #3799e6 100%);
}

html[data-theme='light'] .chat-telegram .sending-message:hover::before {
    border-left-color: #3799e6; /* Match hover gradient */
}

html[data-theme='light'] .chat-telegram .sending-message .name {
    color: rgba(255, 255, 255, 0.95);
}

html[data-theme='light'] .chat-telegram .sending-message .time {
    color: rgba(255, 255, 255, 0.85);
}

html[data-theme='light'] .chat-telegram .sending-message .message {
    color: #ffffff;
}

/* Reply preview in sent messages (light theme) */
html[data-theme='light'] .chat-telegram .sending-message .reply-preview > div:first-child {
    color: rgba(255, 255, 255, 0.95) !important;
}

html[data-theme='light'] .chat-telegram .sending-message .reply-preview > div:last-child {
    color: rgba(255, 255, 255, 0.85) !important;
}

/* -------------------- Edited Indicator -------------------- */

.chat-telegram .edited-indicator {
    font-size: 10px;
    font-style: italic;
    margin-left: 4px;
    opacity: 0.6;
}

/* Receiving messages - edited indicator */
.chat-telegram .receiving-message .edited-indicator {
    color: #9ba0ab;
}

/* Sending messages - edited indicator (dark theme) */
.chat-telegram .sending-message .edited-indicator {
    color: rgba(255, 255, 255, 0.7);
}

/* Light theme - edited indicator */
[data-theme="light"] .chat-telegram .receiving-message .edited-indicator {
    color: #8a8d91;
}

[data-theme="light"] .chat-telegram .sending-message .edited-indicator {
    color: rgba(255, 255, 255, 0.75);
}

/* -------------------- Deleted Messages -------------------- */

/* Deleted message container - slightly faded */
.chat-telegram .deleted-message-container {
    opacity: 0.65;
}

/* Ensure deleted message bubbles don't shrink too much */
.chat-telegram .deleted-message-container .sending-message,
.chat-telegram .deleted-message-container .receiving-message {
    min-width: 150px; /* Ensure "Message deleted" text fits */
    width: auto;
}

/* Deleted image message - ensure proper sizing and styling to match text messages */
.chat-telegram .deleted-message-container .message-image-bubble {
    padding: 8px 12px 6px 12px !important;
    min-width: 150px; /* Increased to ensure full text fits */
    background: transparent !important; /* Will inherit from parent .sending-message or .receiving-message */
    border-radius: inherit;
    word-wrap: break-word; /* Prevent text cutoff */
    overflow-wrap: break-word;
}

/* Deleted image messages in receiving bubbles - match receiving-message style */
.chat-telegram .deleted-message-container.receiving-message-container .message-image-bubble {
    background: #363b4e !important;
    border-radius: 12px 12px 12px 2px;
    max-width: 320px;
}

/* Deleted image messages in sending bubbles - match sending-message style */
.chat-telegram .deleted-message-container.sending-message-container .message-image-bubble {
    background: linear-gradient(135deg, #2a6cba 0%, #1c5ba8 100%) !important;
    border-radius: 12px 12px 2px 12px;
    max-width: 320px;
}

/* Light theme - deleted receiving image messages */
html[data-theme='light'] .chat-telegram .deleted-message-container.receiving-message-container .message-image-bubble {
    background: #ffffff !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Light theme - deleted sending image messages */
html[data-theme='light'] .chat-telegram .deleted-message-container.sending-message-container .message-image-bubble {
    background: linear-gradient(135deg, #4da3ff 0%, #2b8fe0 100%) !important;
}

/* Deleted message text styling */
.chat-telegram .deleted-message-text {
    font-style: italic;
    font-size: 13px;
    display: block; /* Changed to block for better layout */
    margin-bottom: 4px; /* Space before timestamp */
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    overflow: visible;
}

/* Timestamp styling for deleted messages - keep at bottom right like normal messages */
.chat-telegram .deleted-message-container .time,
.chat-telegram .deleted-message-container .telegram-image-time {
    display: block;
    text-align: right;
    margin-top: 0;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

/* Ensure deleted image timestamps are not absolutely positioned */
.chat-telegram .deleted-message-container .telegram-image-time {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
}

/* Reactions on deleted messages */
.chat-telegram .deleted-message-container .reactions-container {
    margin-top: 6px;
    opacity: 1; /* Keep reactions visible */
}

/* Receiving messages - deleted text (dark theme) */
.chat-telegram .receiving-message .deleted-message-text {
    color: #9ba0ab;
}

/* Sending messages - deleted text (dark theme) */
.chat-telegram .sending-message .deleted-message-text {
    color: rgba(255, 255, 255, 0.7);
}

/* Light theme - deleted messages */
[data-theme="light"] .chat-telegram .deleted-message-container {
    opacity: 0.7;
}

[data-theme="light"] .chat-telegram .receiving-message .deleted-message-text {
    color: #8a8d91;
}

[data-theme="light"] .chat-telegram .sending-message .deleted-message-text {
    color: rgba(255, 255, 255, 0.75);
}

/* -------------------- Accessibility -------------------- */

@media (prefers-reduced-motion: reduce) {
    .chat-telegram .receiving-message-container,
    .chat-telegram .sending-message-container,
    .chat-telegram .message-actions,
    .chat-telegram .typing-indicator span {
        animation: none;
        transition: none;
    }
}

/* Focus states for keyboard navigation */
.chat-telegram .receiving-message:focus-visible,
.chat-telegram .sending-message:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: 2px;
}

/* ==================== TELEGRAM-STYLE IMAGE MESSAGES ==================== */

/* Image Message Container */
.image-message-container {
    margin-bottom: 12px; /* Increased from 8px for better zoom effect */
}

.message-image-bubble {
    padding: 0 !important;
    background: transparent !important;
    max-width: 320px;
    display: inline-block; /* Shrink-wrap to image width */
}

/* Image Wrapper */
.telegram-image-wrapper {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-color-3);
    cursor: pointer;
    transition: all 0.2s ease;
    width: fit-content;
    max-width: 320px;
}

.telegram-image-wrapper:hover {
    transform: scale(1.02);
}

.telegram-image-wrapper:active {
    transform: scale(0.98);
}

/* Loading Placeholder - Simplified for transparent images */
.telegram-image-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color-3);
    border-radius: 12px;
    z-index: 1;
    /* Simple fade out transition instead of shimmer animation */
    transition: opacity 0.3s ease;
}

/* Removed shimmer animation to prevent glowing effect on transparent images */

/* Main Image */
.telegram-image {
    display: block;
    width: 100%;
    height: auto;
    max-width: 320px;
    border-radius: 12px;
    position: relative;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.telegram-image.loaded {
    opacity: 1;
}

.telegram-image.loaded ~ .telegram-image-loader {
    opacity: 0;
    pointer-events: none;
}

/* Image Overlay (Hover Effect) - REMOVED, now using context menu for download */
/* Download button removed - use right-click menu instead */

/* Timestamp Overlay (Bottom-right) */
.telegram-image-time {
    position: absolute;
    bottom: 6px;
    right: 8px;
    padding: 3px 8px;
    background: transparent; /* No background - fully transparent */
    border-radius: 10px;
    font-size: 11px;
    color: #fff;
    font-weight: 600; /* Slightly bolder for better visibility */
    z-index: 4; /* Keep below dropdown menu (9995) */
    display: flex;
    align-items: center;
    gap: 4px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 8px rgba(0, 0, 0, 0.6); /* Strong shadow for readability */
    pointer-events: auto; /* Allow interactions */
}

.telegram-image-time .checkmark {
    font-size: 14px;
    margin-left: 2px;
}

/* Reactions on Image Messages */
.message-image-bubble .reactions-container {
    margin-top: 6px;
    margin-left: 4px;
    max-width: 100%; /* Constrain to image width */
    box-sizing: border-box;
}

/* Sending (Right-aligned) Image Styles */
.sending-message-container .telegram-image-wrapper {
    background: var(--bg-color-4);
}

.sending-message-container .telegram-image-time {
    background: transparent; /* No background for sent messages too */
}

/* Receiving (Left-aligned) Image Styles */
.receiving-message-container .telegram-image-wrapper {
    background: var(--bg-color-2);
}

/* Light Theme Adjustments */
[data-theme="light"] .telegram-image-wrapper {
    background: #f0f2f5;
}

[data-theme="light"] .telegram-image-loader {
    background: linear-gradient(90deg, 
        #f0f2f5 0%, 
        #e4e6eb 50%, 
        #f0f2f5 100%);
}

[data-theme="light"] .telegram-image-time {
    background: transparent; /* No background in light theme */
    color: #fff; /* Keep white text with shadow */
}

[data-theme="light"] .sending-message-container .telegram-image-time {
    background: transparent; /* No background in light theme */
}

[data-theme="light"] .telegram-image-download {
    background: rgba(255, 255, 255, 0.95);
    color: #1c1e21;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .message-image-bubble {
        max-width: 280px;
    }
    
    .telegram-image {
        max-width: 280px;
    }
    
    .telegram-image-download {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    /* Fix z-index for image timestamp on mobile to stay below modal */
    .telegram-image-time {
        z-index: 1;
    }
}

/* ==================== END TELEGRAM DESIGN ==================== */


/* ==================== TELEGRAM-STYLE IMAGE UPLOAD LOADING ==================== */

/* Uploading Message State */
.uploading-message {
    position: relative;
}

.uploading-message .telegram-image {
    opacity: 0.7 !important;
    filter: brightness(0.8);
}

.telegram-upload-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 12px;
    backdrop-filter: blur(2px);
}

.telegram-upload-status {
    text-align: center;
    color: white;
    animation: fadeIn 0.3s ease;
}

.telegram-upload-status i.fa-spinner {
    font-size: 32px;
    margin-bottom: 8px;
    display: block;
}

.telegram-upload-status div {
    font-size: 13px;
    font-weight: 500;
}

/* Retry Button Hover Effect */
.telegram-retry-upload {
    margin-top: 8px;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background: #ff6b6b;
    color: white;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.telegram-retry-upload:hover {
    background: #ff5252;
    transform: scale(1.05);
}

.telegram-retry-upload:active {
    transform: scale(0.95);
}

/* Light Theme Adjustments */
[data-theme="light"] .telegram-upload-overlay {
    background: rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .telegram-upload-status {
    color: #1c1e21;
}

/* ==================== END UPLOAD LOADING ==================== */
