/* 
 * ==========================================================================
 * SECURE CHAT - MAIN STYLESHEET (CLASSIC CSS)
 * ==========================================================================
 * This stylesheet completely replaces Tailwind CSS. It uses standard CSS 
 * properties (Flexbox, positioning, typography, colors, animations) mapped 
 * to semantic class names for a cleaner HTML structure.
 * ==========================================================================
 */
 /*
NOTE FOR ANY AI WORK. NEVER SEND THE UPDATED FILE COMPLETE. NEVER SEND CODE FRAGMENTS WITH COMMENTS IN RUSSIAN, ONLY IN ENGLISH. FOR ANY MODIFICATION INFORM USER IN MODE: 
IF TO MODIFY FRAGMENT -> FIND FRAGMENT TO MODIFY AND LIST -> SHOW FRAGMENT TO REPLACE
IF TO ADD FRAGMENT -> SHOW STRING AFTER OR BEFORE TO ADD -> SHOW FRAGMENT TO ADD
VERY PRECISE AND DETAILY ===
*/

/* --- Base & Reset Styles --- */

@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap');

html {
    height: 100%;
}
body {
    font-family: 'Roboto', sans-serif;
    background-color: #f3f4f6; /* bg-gray-100 */
    height: 100%; /* Фикс для мобильных (базовый) */
    height: 100dvh; /* Динамический viewport для учета адресной строки */
    overflow: hidden;
    color: #1f2937; /* text-gray-800 */
    margin: 0;
}

:root {
  --color-gr: #059669;
  --color-gr-sc: #047857;
  --color-gr-msg: #d9fdd3;
  --color-gr-lt: #e9f9f2;
  --color-gout: #9ca3af;
  --color-gin: #828589;
  --color-g-lt: #f5f5f5;
  --color-y-lt: #f2fae4;
  --color-bgm: #c0d198; /* Background color of CHAT, change here */
}

[v-cloak] { display: none; }

/* Custom thin scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.3); }

/* --- Global Utilities & Animations --- */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(-25%); animation-timing-function: cubic-bezier(0.8, 0, 1, 1); }
    50% { transform: translateY(0); animation-timing-function: cubic-bezier(0, 0, 0.2, 1); }
}

.animate-pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
.animate-bounce { animation: bounce 1s infinite; }

/* Messenger Style Chat Background */
.bg-chat {
    background-color: var(--color-gr);
    background-image: 
        radial-gradient(var(--color-gr-lt) 0.75px, transparent 0.75px),
        radial-gradient(var(--color-gr) 0.75px, 
        var(--color-bgm) 0.75px); /* main back color here*/
    background-size: 30px 30px;
    background-position: 0 0, 15px 15px;
}

/* Pinned Header Banner Container - GRID LAYOUT */
.pinned-header-banner {
    background-color: var(--color-gr-lt);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(229, 231, 235, 0.8);
    padding: 0.5rem 1.5rem;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1rem;
    z-index: 9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: background-color 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.pinned-banner-content {
    border-left: 6px solid var(--color-gr);
    padding-left: 0.75rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pinned-header-banner:hover {
    background-color: var(--color-y-lt);
}

.pinned-banner-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-gr);
    line-height: 1.2;
}

.pinned-banner-text {
    font-size: 0.8125rem;
    color: black;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 0.125rem;
    display: block;
}

/* --- App Layout --- */
.app-container { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.main-layout { display: flex; flex: 1; height: 100%; min-height: 0; overflow: hidden; }

/* --- Login Screen --- */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background-color: #e5e7eb; /* bg-gray-200 */
}
.login-card {
    background-color: #ffffff;
    padding: 2rem; /* p-8 */
    border-radius: 1rem; /* rounded-2xl */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 90%; 
    max-width: 24rem;
    box-sizing: border-box;
    border: 1px solid #f3f4f6;
}
.login-icon {
    width: 4rem; height: 4rem;
    background-color: #10b981; /* bg-emerald-500 */
    border-radius: 50%;
    margin: 0 auto 1rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.875rem; /* text-3xl */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.login-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem; text-align: center; color: #1f2937; }
.login-error {
    background-color: #fef2f2; color: #dc2626; padding: 0.75rem;
    border-radius: 0.75rem; margin-bottom: 1rem; text-align: center; font-size: 0.875rem; border: 1px solid #fee2e2;
}
.input-field {
    width: 100%; 
    padding: 0.75rem 1rem; 
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem; 
    margin-bottom: 0.75rem; 
    font-size: 0.875rem;
    background-color: rgba(249, 250, 251, 0.5); 
    box-sizing: border-box; 
    outline: none; 
    transition: box-shadow 0.2s;
}
.input-field:focus { 
    box-shadow: 0 0 0 1px var(--color-gr); 
}
.btn-primary {
    width: 100%; 
    background-color: var(--color-gr);
    color: white; 
    font-weight: 600;
    padding: 0.75rem 1rem; 
    border-radius: 0.75rem; 
    border: none; 
    cursor: pointer;
    transition: all 0.2s; 
    box-shadow: 0 10px 15px -3px rgba(5, 150, 105, 0.2);
}
.btn-primary:hover { 
    background-color: var(--color-gr-sc); 
}
.btn-primary:disabled { 
    opacity: 0.5; 
    cursor: not-allowed; 
}

/* --- Offline Screen --- */
.offline-screen {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; background-color: #f3f4f6; color: #1f2937; z-index: 50;
}
.offline-icon { font-size: 3.75rem; margin-bottom: 1rem; opacity: 0.7; }
.offline-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.offline-text { color: #6b7280; font-size: 0.875rem; max-width: 24rem; text-align: center; margin-bottom: 1.5rem; }
.status-badge {
    padding: 0.5rem 1rem; background-color: white; border-radius: 9999px;
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05); border: 1px solid #e5e7eb;
    display: flex; align-items: center; gap: 0.5rem; color: #059669; font-weight: 500; font-size: 0.875rem;
}
.status-dot { 
    width: 0.625rem; 
    height: 0.625rem; 
    border-radius: 50%; 
    background-color: var(--color-gr); 
    display: inline-block; 
}
/* --- Sidebar General --- */
.sidebar {
    background-color: white; border-right: 1px solid #e5e7eb;
    display: flex; flex-direction: column; position: relative; transition: width 0.1s;
}
.sidebar-resizer {
    position: absolute; right: 0; top: 0; bottom: 0; width: 2px;
    cursor: col-resize; transition: background-color 0.2s; z-index: 20;
}
.sidebar-resizer:hover { 
    background-color: var(--color-gr); 
}

/* Sidebar Header */
.sidebar-header {
    padding: 1rem; 
    background-color: var(--color-g-lt);
    border-bottom: 1px solid #e5e7eb; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
}
.sidebar-header-left { 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
    cursor: pointer; 
}
.sidebar-header-right { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.avatar-container { position: relative; width: 2.75rem; height: 2.75rem; flex-shrink: 0; }
.avatar-img { 
	width: 100%; 
	height: 100%; 
	border-radius: 50%; 
	object-fit: cover; 
	border: 1px solid var(--color-gr); 
	box-sizing: border-box;
    display: block;
}
.avatar-fallback {
    width: 100%; 
    height: 100%; 
    border-radius: 50%; 
    background-color: var(--color-gr);
    color: white; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-weight: 700; 
    border: 2px solid var(--color-gr); 
    box-sizing: border-box;
}
.avatar-overlay {
    position: absolute; 
	inset: 0;
	color: white;
	background-color: var(--color-gr);
	border-radius: 50%; 
	display: flex; 
	align-items: center; 
	justify-content: center;
    opacity: 0; 
	transition: opacity 0.2s;
}

/* Unified sidebar profile header hover */
.sidebar-header-left:hover .avatar-overlay { opacity: 1; }
.sidebar-header-left:hover .username-text { color: var(--color-gr); }

.username-text { font-weight: 700; color: #111827; line-height: 1.25; transition: color 0.2s; }
.icon-btn {
    cursor: pointer; padding: 0.625rem; color: #9ca3af; background: transparent; border: none;
    border-radius: 0.75rem; transition: all 0.2s; display: flex; align-items: center; justify-content: center;
}
.icon-btn.is-active {
    color: var(--color-gr);
}
.icon-btn:hover, .icon-btn.is-active:hover { 
    color: white; 
    background-color: var(--color-gr); 
}
.icon-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* Sidebar View Headers (Back Buttons) */
.view-header {
    padding: 1rem; border-bottom: 1px solid #e5e7eb; display: flex; align-items: center; gap: 0.75rem;
}
.view-title { font-weight: 700; color: #1f2937; margin: 0; }

/* Chat List */
.scroll-area { flex: 1; overflow-y: auto; }
.chat-list-divider > * { border-bottom: 1px solid #f3f4f6; }
.chat-item { padding: 0.75rem; 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
    user-select: none;
    transition: background-color 0.2s; 
    cursor: pointer;
}
.chat-item.is-draggable {
    cursor: grab;
}
.chat-item.is-draggable:active {
    cursor: grabbing;
}
.chat-item:hover { 
    background-color: var(--color-y-lt); 
}
.chat-item.is-active { 
    background-color: var(--color-gr-lt); 
}
.chat-avatar-container {
    width: 3rem; 
    height: 3rem; 
    border-radius: 50%; 
    background-color: var(--color-gr);
    flex-shrink: 0; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-weight: 700;
    color: white;
    overflow: hidden;
}
.chat-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-item-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.125rem; width: 100%; }
.chat-item-name { 
	font-weight: 600; 
	color: var(--color-gr);
	white-space: nowrap; 
	overflow: hidden; 
	text-overflow: ellipsis; 
	flex: 1; 
	padding-right: 
	0.5rem; 
	}

.chat-item-meta { display: flex; align-items: center; justify-content: flex-end; gap: 0.25rem; flex-shrink: 0; white-space: nowrap; }
.chat-item-time { font-size: 0.6875rem; color: #9ca3af; margin-left: 0.25rem; }
.chat-item-msg { font-size: 0.75rem; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-badge { background-color: #10b981; color: white; border-radius: 9999px; padding: 0.125rem 0.375rem; font-size: 0.625rem; font-weight: 700; min-width: 1.25rem; text-align: center; display: inline-flex; justify-content: center; align-items: center; box-shadow: 0 1px 2px rgba(0,0,0,0.1); flex-shrink: 0; }
.highlight-msg { background-color: rgba(251, 191, 36, 0.25) !important; transition: background-color 0.5s; border-radius: 0.5rem; }

/* Sidebar Profile & Forms */
.profile-pad { padding: 1rem; display: flex; flex-direction: column; gap: 1.5rem; }
.msg-success { background-color: #ecfdf5; color: #047857; padding: 0.75rem; border-radius: 0.75rem; text-align: center; font-size: 0.875rem; border: 1px solid currentColor; }
.msg-error { background-color: #fef2f2; color: #dc2626; padding: 0.75rem; border-radius: 0.75rem; text-align: center; font-size: 0.875rem; border: 1px solid currentColor; }
.large-avatar-wrapper {
    width: 6rem; height: 6rem; border-radius: 50%; overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); border: 4px solid #10b981; margin-bottom: 0.75rem;
    flex-shrink: 0;
}
.upload-label {
    cursor: pointer; background-color: #f3f4f6; color: #374151; font-size: 0.75rem;
    font-weight: 600; padding: 0.5rem 1rem; border-radius: 0.75rem; transition: background-color 0.2s;
}
.upload-label:hover { background-color: #e5e7eb; }
.form-group { display: flex; flex-direction: column; gap: 1rem; }
.form-label { display: block; font-size: 0.75rem; font-weight: 600; color: #4b5563; margin-bottom: 0.25rem; }
.input-disabled { background-color: #f3f4f6; color: #4b5563; cursor: not-allowed; }
.hr-divider { border: 0; border-top: 1px solid #f3f4f6; margin: 0; }
.section-subtitle { font-weight: 700; color: #1f2937; font-size: 0.875rem; margin: 0 0 0.5rem 0; }
.btn-dark { background-color: #1f2937; color: white; width: 100%; padding: 0.625rem; border-radius: 0.75rem; font-weight: 600; font-size: 0.875rem; border: none; cursor: pointer; }

/* User / Room Profile specifics */
.profile-centered { display: flex; flex-direction: column; align-items: center; padding: 1.5rem; flex-shrink: 0; }
.avatar-huge { width: 7rem; height: 7rem; border-radius: 50%; object-fit: cover; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border: 4px solid #10b981; margin-bottom: 1rem; flex-shrink: 0; }
.status-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1.5rem; }
.dot-online { 
    width: 0.75rem; 
    height: 0.75rem; 
    border-radius: 50%; 
    background-color: var(--color-gr); 
}
.dot-offline { width: 0.75rem; height: 0.75rem; border-radius: 50%; background-color: #9ca3af; }
.status-text { font-size: 0.875rem; font-weight: 700; color: #1f2937; }
.profile-name { font-size: 1.25rem; font-weight: 700; color: #1f2937; margin: 0 0 0.25rem 0; text-align: center; }
.profile-email { color: #6b7280; font-size: 0.875rem; margin-bottom: 1.5rem; }
.role-badge { background-color: #f3f4f6; padding: 0.25rem 0.5rem; border-radius: 0.375rem; font-weight: 700; color: #1f2937; }
.member-list { max-height: 12rem; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; }
.member-item { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem; background-color: #f9fafb; border-radius: 0.75rem; border: 1px solid #f3f4f6; }
.member-left { display: flex; align-items: center; gap: 0.5rem; }
.member-avatar { width: 2rem; height: 2rem; border-radius: 50%; object-fit: cover; }
.member-fallback { 
    width: 2rem; 
    height: 2rem; 
    border-radius: 50%; 
    background-color: var(--color-gr); 
    color: white; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 0.75rem; 
    font-weight: 700; 
}
.member-name { font-size: 0.75rem; font-weight: 700; color: #1f2937; }
.member-role { font-size: 0.625rem; color: #6b7280; }
.btn-text-danger { background: none; border: none; color: #ef4444; font-size: 0.75rem; font-weight: 600; padding: 0.25rem 0.5rem; cursor: pointer; }
.btn-text-danger:hover { color: #b91c1c; }
.btn-warning { width: 100%; background-color: #f59e0b; color: white; padding: 0.625rem; border-radius: 0.75rem; font-size: 0.875rem; font-weight: 600; border: none; cursor: pointer; }
.btn-warning:hover { background-color: #d97706; }
.btn-danger { width: 100%; background-color: #dc2626; color: white; padding: 0.625rem; border-radius: 0.75rem; font-size: 0.875rem; font-weight: 600; border: none; cursor: pointer; }
.btn-danger:hover { background-color: #b91c1c; }

/* --- Main Chat Window --- */
.chat-main { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; overflow: hidden; }

/* Header */
.chat-header {
    padding: 1rem; 
    background-color: rgba(255,255,255,0.9);
    backdrop-filter: blur(12px); 
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(229,231,235,0.8); 
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    z-index: 10;
}
.header-info { display: flex; align-items: center; gap: 0.75rem; }
.header-info.is-clickable { cursor: pointer; }
.header-info.is-clickable:hover .avatar-overlay { opacity: 1; }
.header-info.is-clickable:hover .header-name { color: var(--color-gr); }

.header-avatar { 
    width: 2.5rem; 
    height: 2.5rem; 
    border-radius: 50%; 
    object-fit: cover; 
    border: 1px solid var(--color-gr); 
}
.header-fallback { width: 2.5rem; height: 2.5rem; border-radius: 50%; background-color: #059669; color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; border: 2px solid #10b981; }
.header-name { font-weight: 700; color: #111827; font-size: 1rem; transition: color 0.2s; }

.member-name-row { display: flex; align-items: center; gap: 0.375rem; }
.member-meta-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.125rem; }
.member-last-seen { font-size: 0.625rem; color: #9ca3af; }
.header-stats { font-size: 0.75rem; color: #6b7280; display: flex; align-items: center; gap: 0.5rem; margin-top: 0.125rem; }
.stat-dot { color: #d1d5db; }
.stat-online { 
    color: var(--color-gr);
    font-weight: 500; 
    display: flex; 
    align-items: center; 
    gap: 0.375rem; 
}
.stat-indicator { 
    width: 0.5rem; 
    height: 0.5rem; 
    border-radius: 50%; 
    background-color: var(--color-gr); 
    display: inline-block; 
}
.header-actions-panel { display: flex; align-items: center; }
.header-status-badge {
    font-size: 0.75rem; background-color: rgba(243,244,246,0.8);
    border: 1px solid rgba(229,231,235,0.6); padding: 0.375rem 0.875rem;
    border-radius: 0.75rem; display: flex; align-items: center; gap: 0.5rem; box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
}
.status-typing { color: #059669; font-weight: 600; display: flex; align-items: center; gap: 0.375rem; }
.status-activity { color: #4f46e5; font-weight: 500; }
.status-offline-text { color: #9ca3af; font-weight: 500; }

/* Header Notifications Settings */
.header-settings { display: flex; align-items: center; gap: 0.25rem; margin-left: 0.5rem; }
.icon-btn-small { background: none; border: none; cursor: pointer; color: var(--color-gr); padding: 0.375rem; border-radius: 0.5rem; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.icon-btn-small:hover { background-color: var(--color-gr-lt); }
.icon-btn-small.is-off { color: #9ca3af; }
.icon-btn-small.is-off:hover { background-color: #f3f4f6; color: #4b5563; }
.icon-btn-small svg { width: 18px; height: 18px; display: block; }

/* Messages Feed */
.message-feed-wrapper { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; overflow: hidden; }
.message-feed { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 1.5rem; display: flex; flex-direction: column; gap: 0.75rem; }

/* Scroll to Bottom Button */
.scroll-down-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    z-index: 20;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.scroll-down-btn:hover {
    background-color: white;
    color: var(--color-gr);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}
.scroll-down-btn svg { width: 24px; height: 24px; display: block; }

/* Vue Transition classes */
.fade-enter-active, .fade-leave-active { transition: opacity 0.3s, transform 0.3s; }
.fade-enter-from, .fade-leave-to { opacity: 0; transform: translateY(10px) scale(0.9); }

.date-divider-wrap { display: flex; justify-content: center; margin: 0.75rem 0; width: 100%; }
.date-divider {
    background-color: var(--color-gr); 
    backdrop-filter: blur(4px); 
    -webkit-backdrop-filter: blur(4px);
    color: white; 
    font-size: 0.8rem; 
    font-weight: 700; 
    padding: 0.25rem 0.75rem;
    border-radius: 9999px; 
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
}
.pagination-btn {
    transition: background-color 0.2s;
}
.pagination-btn:hover {
    background-color: var(--color-gr-sc);
}

.msg-row { display: flex; align-items: center; gap: 0.625rem; width: 100%; }
.msg-row-out { justify-content: flex-end; }
.msg-row-in { justify-content: flex-start; }

.select-checkbox {
    width: 1rem; 
    height: 1rem; 
    color: var(--color-gr); 
    border-radius: 0.25rem;
    border-color: #d1d5db; 
    cursor: pointer; 
    flex-shrink: 0; 
    transition: all 0.2s;
}

/* Hover Actions */
.msg-actions {
    opacity: 0; transition: opacity 0.2s; display: flex; align-items: center; gap: 0.25rem;
    background-color: rgba(255,255,255,0.95); backdrop-filter: blur(12px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border-radius: 0.75rem;
    padding: 0.375rem; border: 1px solid #f3f4f6; flex-shrink: 0;
}
.msg-row:hover .msg-actions { opacity: 1; }
.action-btn { 
    padding: 0.375rem; 
    border-radius: 0.5rem; 
    color: var(--color-gr);
    background: none; 
    border: none; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    transition: background-color 0.2s; 
}
.action-btn:hover {
    background-color: var(--color-gr);
    color: white;
}
.action-btn-danger { 
    color: #dc2626; 
}
.action-btn-danger:hover { 
    background-color: #dc2626;
    color: white;
}

/* Drag and Drop Overlay */
.drop-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.9);
    border: 4px dashed var(--color-gr);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--color-gr);
    font-size: 1.5rem;
    font-weight: 700;
    border-radius: 1rem;
    margin: 1rem;
}
.drop-overlay svg { width: 64px; height: 64px; margin-bottom: 1rem; }

/* Reactions Menu (WhatsApp Style) */
.reaction-menu-container {
    position: absolute;
    bottom: 100%;
    margin-bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 0.75rem;
    padding: 0.25rem;
    display: flex;
    gap: 0.125rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    border: 1px solid #e5e7eb;
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}
.msg-actions-wrap { position: relative; display: flex; align-items: center; }
.msg-actions-wrap:hover .reaction-menu-container, 
.reaction-menu-container:hover {
    opacity: 1;
    visibility: visible;
}
.reaction-emoji-btn {
    background: none;
    border: none;
    color: var(--color-gr);
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
}
.reaction-emoji-btn:hover {
    background-color: var(--color-gr);
    color: white;
}
.reaction-emoji-btn svg {
    width: 18px;
    height: 18px;
    display: block;
}
.reaction-emoji-btn.cancel-reaction {
    color: #dc2626;
    font-size: 1rem;
    font-weight: bold;
}
.reaction-emoji-btn.cancel-reaction:hover {
    background-color: #dc2626;
    color: white;
}

/* Displayed Reactions under Message (Telegram Style) */
.reactions-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.25rem;
}
.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(255,255,255,0.7);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 1rem;
    padding: 0.125rem 0.375rem;
    font-size: 0.8125rem;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: background-color 0.2s;
    color: var(--color-gr);
}
.reaction-icon-wrap {
    display: flex;
    align-items: center;
    color: var(--color-gr);
}
.bubble-in .reaction-pill { 
	background: var(--color-gr-lt); 
	}
.reaction-pill:hover { 
	background: var(--color-y-lt); 
	}
.reaction-pill-avatars { display: flex; align-items: center; }
.reaction-avatar-mini {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    object-fit: cover;
	background: var(--color-gr);
    margin-left: -0.25rem;
    border: 1px solid white;
}
.reaction-avatar-mini:first-child { margin-left: 0; }
.reaction-count-text { font-weight: 600; color: #4b5563; font-size: 0.75rem; margin-left: 0.125rem; }

/* Reactions Modal */
.reaction-user-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px solid #f3f4f6;
}
.reaction-user-item:last-child { border-bottom: none; }
.reaction-user-avatar { width: 2.5rem; height: 2.5rem; border-radius: 50%; object-fit: cover; }
.reaction-user-info { flex: 1; display: flex; flex-direction: column; }
.reaction-user-name { font-weight: 600; color: #111827; font-size: 0.875rem; }
.reaction-time { font-size: 0.75rem; color: #9ca3af; }
.reaction-big-emoji { font-size: 1.5rem; }

.action-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* --- Tasks Module --- */
.task-header-block {
    background-color: rgba(255, 255, 255, 0.6);
    border-radius: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}
.task-active { background-color: var(--color-g-lt); }
.task-completed { border-color: #6ee7b7; background-color: #d1fae5; opacity: 0.8; }
.task-cancelled { border-color: #d1d5db; background-color: #f3f4f6; opacity: 0.8; }

.task-title-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.task-badge { color: #dc2626; font-weight: 800; font-size: 0.875rem; }
.task-badge-completed { color: #059669 !important; }
.task-badge-cancelled { color: #dc2626 !important; }
.task-overdue-badge { color: white; background-color: #dc2626; font-size: 0.7rem; font-weight: 700; padding: 0.125rem 0.375rem; border-radius: 0.25rem; animation: pulse 2s infinite; }
.task-meta { font-size: 0.75rem; color: #4b5563; }
.task-assignee { font-weight: 700; color: #1f2937; margin-left: 0.25rem; }
.task-controls { display: flex; gap: 0.5rem; margin-top: 0.25rem; flex-wrap: wrap; }

.msg-row-center { justify-content: center; position: relative; width: 100%; }
.transient-event-wrapper { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; }
.transient-event-wrapper .msg-actions { position: absolute; right: 0; opacity: 0; pointer-events: none; }
.transient-event-wrapper:hover .msg-actions { opacity: 1; pointer-events: auto; }

.transient-event-message {
    background-color: rgba(0,0,0,0.6);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    text-align: center;
}
.transient-event-message.bubble-selected {
    box-shadow: 0 0 0 2px var(--color-gr);
}

/* Bubbles */
.msg-sender-avatar-wrap { flex-shrink: 0; align-self: flex-end; margin-bottom: 0.25rem; cursor: pointer; }
.msg-sender-img { width: 2rem; height: 2rem; border-radius: 50%; object-fit: cover; box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05); }
.msg-sender-fallback { 
    width: 2rem; 
    height: 2rem; 
    border-radius: 50%; 
    background-color: var(--color-gr); 
    color: white; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-weight: 700; 
    font-size: 0.75rem; 
}

.msg-bubble {
    padding: 0.75rem; 
    max-width: 28rem; 
    border: 1px solid transparent;
    position: relative; 
    padding-right: 4.5rem; 
    padding-bottom: 1.25rem;
    font-size: 0.875rem; 
    transition: all 0.2s;
    box-sizing: border-box;
}
.bubble-out { 
    background-color: var(--color-gr-msg); 
    color: black; 
    border-radius: 1rem; 
    border-bottom-right-radius: 0.125rem; 
}
.bubble-in { 
    background-color: white; 
    color: black; 
    border-radius: 1rem; 
    border-bottom-left-radius: 0.125rem; 
}
.bubble-selected { 
    cursor: pointer; 
    border: 1px solid var(--color-gr);
}

.bubble-sender-name { 
    font-size: 0.8rem; 
    font-weight: 700; 
    color: var(--color-gr);
    cursor: pointer; 
    transition: color 0.2s; 
    display: inline-block; 
    margin-bottom: 0.25rem; }
.bubble-sender-name:hover { 
    color: var(--color-gr-sc); 
}

.quote-block {
    background-color: var(--color-gr-lt); 
    padding: 0.5rem; 
    border-radius: 0.5rem;
    margin-bottom: 0.375rem; 
    font-size: 0.75rem; 
    cursor: pointer; 
    border-left: 4px solid var(--color-gr);
}
.quote-sender { font-weight: 700; color: #065f46; display: block; }
.quote-text { color: #4b5563; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.edit-mode-block { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.25rem; }
.edit-input { border: 1px solid #d1d5db; border-radius: 0.5rem; padding: 0.375rem 0.625rem; color: #1f2937; font-size: 0.875rem; outline: none; width: 100%; box-sizing: border-box; resize: vertical; min-height: 4rem; max-height: 15rem; font-family: inherit; line-height: 1.4; background-color: white; }
.edit-input:focus { 
    border-color: #d1d5db; 
	box-shadow: 0 0 0 1px var(--color-gr);
    /* box-shadow: inset 0 0 0 1px var(--color-gr); */
}
.edit-actions { display: flex; gap: 0.5rem; font-size: 0.75rem; }

/* File Rendering in Messages */
.msg-img-content { max-width: 100%; border-radius: 0.75rem; margin-bottom: 0.25rem; max-height: 15rem; object-fit: cover; cursor: pointer; transition: opacity 0.2s; }
.msg-img-content:hover { opacity: 0.9; }

.image-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 20rem; /* Ограничиваем максимальную высоту для сильно вытянутых (вертикальных) картинок */
    border-radius: 0.75rem;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.05);
}
.full-image { 
    width: 100% !important; 
    height: 100% !important; 
    max-width: none !important;
    max-height: none !important;
    object-fit: cover;
    display: block; 
    margin: 0; 
}
.thumbnail-container { 
    position: absolute; 
    inset: 0; 
    width: 100%; 
    height: 100%; 
}
.blur-effect {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover;
    filter: blur(8px);
    transform: scale(1.1); /* Скрываем края размытия */
    display: block;
    margin: 0;
}
.show-image-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: background-color 0.2s;
}
.show-image-overlay:hover {
    background-color: rgba(0, 0, 0, 0.3);
}
.show-image-btn {
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--color-gr-sc);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.file-block { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.25rem 0; }
.file-card { display: flex; align-items: center; gap: 0.75rem; background-color: rgba(255,255,255,0.5); padding: 0.5rem; border-radius: 0.5rem; border: 1px solid rgba(0,0,0,0.1); }
.file-icon-pdf { width: 2rem; height: 2rem; background-color: #ef4444; border-radius: 0.25rem; display: flex; align-items: center; justify-content: center; color: white; font-size: 0.625rem; font-weight: 700; }
.file-icon-generic { width: 2rem; height: 2rem; background-color: #6b7280; border-radius: 0.25rem; display: flex; align-items: center; justify-content: center; color: white; }
.file-details { display: flex; flex-direction: column; overflow: hidden; }
.file-name { font-size: 0.8rem; font-weight: 700; color: #374151; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9rem; }
.file-link { color: #059669; font-size: 0.6875rem; text-decoration: underline; }

.msg-text-content { word-break: break-word; overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.625; }
.msg-time { position: absolute; bottom: 0.25rem; right: 0.625rem; font-size: 0.625rem; color: #9ca3af; font-weight: 500; user-select: none; display: flex; align-items: center; }
.msg-status-dots { display: inline-flex; gap: 2px; margin-left: 4px; align-items: center; }
.status-dot-small { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.status-dot-small.gray { background-color: #9ca3af; }
.status-dot-small.green { 
    background-color: var(--color-gr); 
}

/* --- Chat Footer (Input) --- */
.chat-footer { background-color: white; border-top: 1px solid #e5e7eb; display: flex; flex-direction: column; box-shadow: 0 -4px 6px -1px rgba(0,0,0,0.1); flex-shrink: 0; z-index: 10; padding-bottom: env(safe-area-inset-bottom, 0px); }
/* Task Input Disabled States */
.chat-input.is-disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
    pointer-events: none;
}
.send-btn.is-disabled {
    background-color: #d1d5db !important;
    color: white !important;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
}
.attach-label.is-disabled {
    color: #d1d5db;
    cursor: not-allowed;
    pointer-events: none;
}
/* Reply Banner - GRID LAYOUT */
.reply-banner { 
    background-color: var(--color-gr-lt); 
    padding: 0.5rem 1rem; 
    border-bottom: 1px solid var(--color-g-lt);  
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem; 
    width: 100%;
    box-sizing: border-box;
}
.reply-banner-content { 
    border-left: 6px solid var(--color-gr); 
    padding-left: 0.75rem; 
    overflow: hidden;
}
.reply-banner-title { 
    font-weight: 700; 
    color: var(--color-gr); 
    font-size: 0.75rem; 
}
.reply-banner-text { 
    color: black; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    font-size: 0.8125rem; 
    margin-top: 0.125rem; 
    display: block;
}
.reply-close-btn { 
    color: var(--color-gout); 
    font-weight: 700; 
    padding: 0; 
    font-size: 1.125rem; 
    cursor: pointer; 
    background: none; 
    border: none; 
}
.reply-close-btn:hover { 
    color: var(--color-gr); 
}

.input-row { padding: 0.75rem 1rem; display: flex; align-items: center; gap: 0.75rem; position: relative; }
.attach-label { cursor: pointer; padding: 0.625rem; color: #374151; border-radius: 0.75rem; transition: all 0.2s; display: flex; align-items: center; justify-content: flex-start; gap: 0.5rem; width: 100%; box-sizing: border-box; font-size: 0.875rem; font-weight: 500;}
.attach-label:hover { color: var(--color-gr); background-color: #f3f4f6; }

/* Actions pop-up menu styles (HOVER BASED) */
.actions-menu-wrapper { position: relative; }
.actions-popup-panel { 
    position: absolute; bottom: calc(100% + 0.5rem); left: 0; 
    background-color: rgba(255,255,255,0.95); backdrop-filter: blur(12px); 
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.2); border: 1px solid #e5e7eb; border-radius: 1rem; 
    padding: 0.5rem; display: flex; flex-direction: column; gap: 0.25rem; z-index: 40; min-width: 160px; 
    
    /* Состояние по умолчанию: спрятано */
    opacity: 0; visibility: hidden; pointer-events: none; transition: all 0.2s ease; transform: translateY(5px);
}
/* Показываем при наведении */
.actions-menu-wrapper:hover .actions-popup-panel {
    opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0);
}
/* Чтобы меню не скрывалось, если перевести мышку чуть выше кнопки */
.actions-menu-wrapper::before {
    content: ""; position: absolute; top: -10px; left: 0; right: 0; height: 10px;
}
.actions-popup-btn { background: none; border: none; cursor: pointer; padding: 0.625rem; color: #374151; border-radius: 0.75rem; transition: all 0.2s; display: flex; align-items: center; justify-content: flex-start; gap: 0.5rem; width: 100%; font-size: 0.875rem; font-weight: 500; font-family: inherit;}
.actions-popup-btn:hover { color: var(--color-gr); background-color: #f3f4f6; }
.actions-popup-btn svg { width: 18px; height: 18px; }
.chat-input { 
    flex: 1; 
    background-color: #f3f4f6; 
    border: 2px solid transparent; 
    border-radius: 24px; 
    padding: 0.75rem 1.25rem; 
    font-size: 0.875rem; 
    line-height: 1.4;
    outline: none; 
    transition: all 0.2s;
    /* Force height to a single line, hide scrollbar visually but allow internal scrolling */
    height: 45px !important;
    min-height: 45px !important;
    max-height: 45px !important;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
.chat-input::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}
.chat-input:focus {
    background-color: white;
	/* border: 1px solid var(--color-gr); */
	box-shadow: 0 0 0 1px var(--color-gr);	
}
.send-btn { 
    background-color: var(--color-gr);
    color: white; 
    border-radius: 50%; 
    width: 2.75rem; 
    height: 2.75rem; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    box-shadow: 0 10px 15px -3px rgba(5,150,105,0.2); 
    border: none; 
    cursor: pointer; 
    flex-shrink: 0; 
    transition: background-color 0.2s; 
}
.send-btn:hover { 
    background-color: var(--color-gr-sc);
	color: var(--color-gr-lt);
}

/* Empty Chat */
.empty-chat { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #6b7280; }
.empty-icon-wrap { 
    width: 5rem; 
    height: 5rem; 
    background-color: var(--color-gr-lt);
    backdrop-filter: blur(4px); 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    color: var(--color-gr);
    font-size: 2.25rem;
    border: solid 1px var(--color-gr);
    margin-bottom: 0.75rem; 
}
.empty-icon-wrap svg {
  width: 40px;
  height: 40px;
  display: block;
}


.empty-text { font-weight: 500; color: #4b5563; }

/* Contenteditable structural layout properties */
.rich-input {
    min-height: 20px;
    max-height: 180px;
    overflow-y: auto;
    word-break: break-word;
    white-space: pre-wrap;
    text-align: left;
    box-sizing: border-box;
}

.rich-input:empty::before {
    content: attr(placeholder);
    color: #9ca3af;
    cursor: text;
}

/* Floating dynamic styling box overlay */
.floating-format-toolbar {
    position: absolute;
    transform: translate(-50%, -100%);
    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    padding: 0.25rem;
    gap: 0.25rem;
    z-index: 1000;
}

.format-btn {
    width: 28px;
    height: 28px;
    border-radius: 0.25rem;
    background: transparent;
    border: none;
    color: #374151;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.format-btn:hover,
.format-btn.is-active {
    background-color: var(--color-gr);
    color: white;
}

.inline-formatting-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.75rem;
    padding-left: 0.75rem;
    border-left: 1px solid #e5e7eb;
}

.color-picker-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 0.25rem;
    cursor: pointer;
}
.color-picker-wrapper:hover {
    background-color: var(--color-gr);
    color: white;
}
.color-picker-icon {
    font-family: Roboto, serif;
    font-weight: 900;
    font-size: 15px;
    color: #374151;
    border-bottom: 4px solid #000;
    line-height: 1;
    padding-bottom: 1px;
    pointer-events: none; /* Чтобы клик проваливался до скрытого инпута */
    transition: color 0.2s;
}
.color-picker-wrapper:hover .color-picker-icon {
    color: white;
}
.format-color-picker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Floating Selection Panel */
.selection-panel { 
    position: absolute; 
    bottom: 5rem; 
    left: 50%; 
    transform: translateX(-50%); 
    background-color: rgba(255,255,255,0.95); 
    backdrop-filter: blur(12px); 
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); 
    border: 1px solid var(--color-gr);
    padding: 0.75rem 1.5rem; 
    border-radius: 1rem; 
    display: flex; 
    align-items: center; 
    gap: 1rem;
    z-index: 30; 
    transition: all 0.2s; 
}
.selection-count { font-size: 0.875rem; font-weight: 700; color: #374151; }
.vertical-divider { height: 1.25rem; width: 1px; background-color: #e5e7eb; }
.selection-actions { display: flex; align-items: center; gap: 0.5rem; }

/* Modals */
.modal-overlay { position: fixed; inset: 0; background-color: rgba(0,0,0,0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card { background-color: white; border-radius: 1rem; padding: 1.5rem; width: 90%; max-width: 24rem; box-sizing: border-box; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); border: 1px solid #f3f4f6; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-title { font-size: 1.125rem; font-weight: 700; color: #1f2937; margin: 0; }
.modal-close { color: #9ca3af; border: none; background: none; font-weight: 700; font-size: 1.125rem; cursor: pointer; }
.modal-close:hover { color: #4b5563; }
.modal-input { 
    width: 100%; 
    border: 1px solid #e5e7eb; 
    border-radius: 0.75rem; 
    padding: 0.75rem 1rem; 
    margin-bottom: 1.5rem; 
    font-size: 0.875rem; 
    background-color: #f9fafb; 
    outline: none; 
    box-sizing: border-box; 
}
.modal-input:focus { 
    box-shadow: 0 0 0 1px var(--color-gr); 
}
.modal-footer { display: flex; justify-content: flex-end; gap: 0.75rem; }
.btn-modal-cancel { padding: 0.625rem 1rem; background-color: #f3f4f6; color: #374151; border-radius: 0.75rem; font-size: 0.875rem; font-weight: 500; border: none; cursor: pointer; }
.btn-modal-cancel:hover { background-color: #e5e7eb; }
.btn-modal-submit { 
    padding: 0.625rem 1.25rem; 
    background-color: var(--color-gr); 
    color: white; 
    border-radius: 0.75rem; 
    font-size: 0.875rem; 
    font-weight: 500; 
    border: none; 
    cursor: pointer; 
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); 
}
.btn-modal-submit:hover { 
    background-color: var(--color-gr-sc);  
}
.btn-modal-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forward List */
.forward-list { max-height: 15rem; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid #f9fafb; }
.forward-item { padding: 0.75rem; border-radius: 0.75rem; border: 1px solid #e5e7eb; cursor: pointer; display: flex; align-items: center; justify-content: space-between; transition: background-color 0.2s; }
.forward-item:hover { background-color: #f9fafb; }
.forward-item.is-selected { background-color: #ecfdf5; border-color: #6ee7b7; }
.forward-name { font-weight: 500; color: #1f2937; }
.forward-check { color: #059669; font-weight: 700; }

/* Lightbox */
.lightbox-overlay { position: fixed; inset: 0; z-index: 100; background-color: rgba(0,0,0,0.9); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.lightbox-img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: pointer; }
.lightbox-actions { position: absolute; top: 1rem; right: 1rem; display: flex; gap: 1rem; }
.lightbox-download { color: white; font-size: 0.875rem; background-color: rgba(255,255,255,0.2); padding: 0.5rem 1rem; border-radius: 0.5rem; text-decoration: none; }
.lightbox-download:hover { background-color: rgba(255,255,255,0.4); }
.lightbox-close { color: white; font-size: 1.5rem; font-weight: 700; padding: 0 1rem; background: none; border: none; cursor: pointer; }
/* --- Mobile Adaptive Layout (WhatsApp / Telegram style) --- */
.mobile-back-btn { display: none; margin-right: 0.5rem; }

@media (max-width: 768px) {
    /* 1 & 2 & 5. Toggling between Sidebar and Chat */
    .main-layout { flex-direction: column; }
    .sidebar { width: 100% !important; border-right: none; flex: 1; min-height: 0; height: 100%; }
    .sidebar-resizer { display: none !important; }
    
    /* Logic: If mobile-show-chat is active, hide sidebar and show chat. Otherwise hide chat and show sidebar. */
    .main-layout:not(.mobile-show-chat) .chat-main { display: none; }
    .main-layout.mobile-show-chat .sidebar { display: none; }
    .main-layout.mobile-show-chat .chat-main { display: flex; width: 100%; height: 100%; overflow: hidden; }

    /* 3. Mobile Back Button */
    .mobile-back-btn { display: flex; }

    /* 4. Mobile Msg Actions Context Menu */
    .msg-row { position: relative; } /* Necessary to anchor the absolute menu */
    
    .msg-actions {
        opacity: 0; 
        pointer-events: none;
        position: absolute; 
        top: -3.5rem;
        flex-wrap: wrap;
        justify-content: center;
        background: rgba(255,255,255,0.98);
        border: 1px solid #e5e7eb;
        box-shadow: 0 10px 15px -3px rgba(0,0,0,0.2);
        transition: opacity 0.2s, transform 0.2s;
        transform: translateY(10px);
        z-index: 50;
    }
    
    /* Align properly over the bubble */
    .msg-row-out .msg-actions { right: 0; transform-origin: bottom right; }
    .msg-row-in .msg-actions { left: 0; transform-origin: bottom left; }
    
    /* Activate via JS Class instead of Hover */
    .msg-actions.mobile-actions-active {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }
    
    /* Disable desktop hover effect on mobile */
    .msg-row:hover .msg-actions:not(.mobile-actions-active) {
        opacity: 0; pointer-events: none; transform: translateY(10px);
    }

    /* 6. Fixes for mobile inputs and spaces */
    .login-card, .modal-card { padding: 1.25rem; }
    .chat-header { padding: 0.75rem 1rem; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .header-info { width: 100%; }
    .header-actions-panel { width: 100%; justify-content: space-between; }
    .header-name { font-size: 0.95rem; }
    .header-stats { font-size: 0.7rem; }
    .input-row { padding: 0.5rem; gap: 0.5rem; }
    .chat-input { padding: 0.5rem 1rem; }
    
    /* 7. Constraints for chat bubbles on mobile */
    .message-feed { padding: 0.75rem 0.5rem; }
    .msg-bubble { max-width: 88%; }
    .image-wrapper { max-width: 100% !important; height: auto !important; }
    .msg-img-content { max-width: 100% !important; }
}

/* --- Search Mode Styles --- */
.search-active-feed .msg-row {
    transition: filter 0.4s ease, opacity 0.4s ease;
}

/* Блюрим всё, кроме совпадающих сообщений */
.search-active-feed .msg-row:not(.is-match) {
    filter: blur(4px) grayscale(50%);
    opacity: 0.3;
    pointer-events: none; /* Чтобы случайно не кликнуть в размытое */
}

/* Подсветка ТЕКУЩЕГО выбранного сообщения (постоянный слегка затемненный фон) */
.msg-row.search-highlight {
    background-color: rgba(0, 0, 0, 0.06); 
    border-radius: 0.5rem;
    box-shadow: 0 0 0 6px rgba(0, 0, 0, 0.06); /* Имитация небольшого отступа без сдвига верстки */
    transition: background-color 0.3s, box-shadow 0.3s;
}

/* Панель кнопок Вверх/Вниз для поиска */
.search-nav-panel {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 20;
}

.search-nav-panel .nav-btn {
    position: static; /* Отменяем absolute от базового scroll-down-btn */
}

.search-nav-panel .nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}
/* --- Upload Preview Modal Specifics --- */
.upload-preview-image {
    max-width: 100%;
    max-height: 220px;
    object-fit: contain;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}
.upload-preview-generic {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: #f3f4f6;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}