* {
box-sizing: border-box;
margin: 0;
padding: 0;
}

:root {
    --primary-color: #4243dc;
    --primary-hover: #2b7fd6;
    --primary-light: #e3f2fd;
    --secondary-color: #4243dc;
    --success-color: #4fce5d;
    --danger-color: #e53935;
    --warning-color: #ff9800;

    /* Neutral colors */
    --bg-main: #f4f4f5;
    --bg-chat: #ffffff;
    --bg-message-in: #ffffff;
    --bg-message-out: #e3f3cb;
    --bg-hover: #f5f5f5;
    --bg-active: #e8e8e8;

    /* Text colors */
    --text-primary: #000000;
    --text-secondary: #707579;
    --text-tertiary: #aaaaaa;
    --text-white: #ffffff;

    /* Borders */
    --border-color: #e4e4e4;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.15);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.35s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.hidden {
    display: none !important;
}

/* ====================== AUTH SECTION ====================== */
.auth-container {
    background: var(--bg-chat);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
    animation: slideUp 0.4s ease;
}

.header-logo {
    width: 48px;
    height: 48px;
    vertical-align: middle;
    margin-right: 6px;
    border-radius: 6px;
    object-fit: contain;
}

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

.auth-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--text-white);
    padding: 32px 28px;
    text-align: center;
}

.auth-header h1 {
    font-size: 26px;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.auth-header p {
    opacity: 0.9;
    font-size: 14px;
    font-weight: 400;
}

.auth-form-container {
    padding: 28px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 15px;
    transition: var(--transition-fast);
    background: var(--bg-chat);
    color: var(--text-primary);
}

.form-control:focus {
    border-color: var(--primary-color);
    outline: none;
    background: var(--bg-chat);
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

.form-btn {
    background: var(--primary-color);
    color: var(--text-white);
    border: none;
    width: 100%;
    padding: 13px;
    border-radius: var(--border-radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-top: 8px;
}

.form-btn:hover {
    background: var(--primary-hover);
}

.form-btn:active {
    transform: scale(0.98);
}

.switch-form {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.switch-form a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.switch-form a:hover {
    color: var(--primary-hover);
}

.error {
    color: var(--danger-color);
    background: #ffebee;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    margin: 16px 0;
    display: none;
    border-left: 3px solid var(--danger-color);
    font-size: 14px;
}

/* ====================== CHAT INTERFACE ====================== */
.chat-container {
    display: none;
    width: 100vw;
    height: 100vh;
    background: var(--bg-main);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-header {
    background: var(--bg-chat);
    color: var(--text-primary);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.chat-header h2 {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.chat-header h2 i {
    color: var(--primary-color);
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-hover);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-offline {
    background: var(--danger-color);
}

/* ====================== TABS ====================== */
.tabs {
    display: flex;
    background: var(--bg-chat);
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    padding: 14px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab:hover {
    color: var(--primary-color);
    background: var(--bg-hover);
}

.tab.active {
    border-bottom: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 110px);
}

/* ====================== CHAT LAYOUT ====================== */
.chat-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: var(--bg-main);
}

.sidebar {
    width: 320px;
    background: var(--bg-chat);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

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

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

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

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-chat);
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-title i {
    color: var(--primary-color);
}

.sidebar-action {
    background: var(--primary-color);
    color: var(--text-white);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: var(--transition-fast);
}

.sidebar-action:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.sidebar-action:active {
    transform: scale(0.95);
}

/* ====================== CHAT ITEMS ====================== */
.chat-list, .user-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.chat-item, .user-item {
    padding: 12px 16px;
    margin: 0;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--bg-main);
}

.chat-item:hover, .user-item:hover {
    background: var(--bg-hover);
}

.chat-item.active, .user-item.active {
    background: var(--primary-light);
    border-left: 3px solid var(--primary-color);
}

.chat-avatar, .user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--text-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-details, .user-details {
    flex: 1;
    min-width: 0;
}

.chat-name, .user-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-last-message, .user-status-text {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time, .user-handle {
    font-size: 12px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.chat-type {
    font-size: 11px;
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 10px;
    color: var(--primary-color);
    font-weight: 500;
}

.private-chat {
    background: #e8f5e9;
    color: var(--success-color);
}

/* ====================== MESSAGES PANEL ====================== */
.messages-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    position: relative;
    overflow: hidden;
    height: 100%;
}

.chat-header-panel {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-chat);
    box-shadow: var(--shadow-sm);
}

.chat-header-info {
    flex: 1;
}

.chat-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-member-count {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.chat-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.typing-indicator {
    text-align: left;
    padding: 10px 20px;
    font-style: italic;
    color: var(--text-secondary);
    display: none;
    background: var(--bg-chat);
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
}

/* ====================== IMPROVED MESSAGES CONTAINER ====================== */
.messages-container {
    overflow-y: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 8px;
}

.chat-messages-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    position: relative;
}

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

.message {
    max-width: 70%;
    padding: 12px 16px;
    margin: 4px 0;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    animation: messageSlide 0.3s ease;
    box-shadow: var(--shadow-sm);
    line-height: 1.4;
}

.message.user {
    background: var(--bg-message-in);
    border: 1px solid var(--border-color);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.self {
    background: var(--bg-message-out);
    border: 1px solid #d0f0c0;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.system {
    background: #fff8e1;
    border: 1px solid #ffd54f;
    text-align: center;
    margin: 8px auto;
    max-width: 85%;
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    box-shadow: none;
}

.message.private {
    background: #f3e5f5;
    border: 1px solid #ce93d8;
    margin: 8px auto;
    max-width: 90%;
    border-radius: var(--border-radius-md);
}

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 13px;
    align-items: center;
}

.message-username {
    font-weight: 600;
    color: var(--primary-color);
}

.message.self .message-username {
    color: var(--success-color);
}

.message.private .message-username {
    color: #7b1fa2;
}

.message-time {
    color: var(--text-tertiary);
    font-size: 11px;
    margin-left: 8px;
}

.message-text {
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
    color: var(--text-primary);
}

.system-badge {
    background: var(--warning-color);
    color: var(--text-white);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 11px;
}

/* ====================== FIXED CHAT INPUT ====================== */
.chat-input {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-chat);
    position: sticky;
    bottom: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

.message-input {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: 15px;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: var(--transition-fast);
    font-family: inherit;
    line-height: 1.4;
}

.message-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.message-input::placeholder {
    color: var(--text-tertiary);
}

.input-actions {
    display: flex;
    gap: 8px;
}

.action-btn, .send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn {
    background: var(--bg-hover);
    color: var(--primary-color);
}

.action-btn:hover {
    background: var(--primary-light);
    transform: scale(1.05);
}

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

.send-btn {
    background: var(--primary-color);
    color: var(--text-white);
}

.send-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

/* ====================== NOTIFICATIONS ====================== */
.notifications-panel {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.notification-item {
    padding: 16px;
    background: var(--bg-chat);
    border-radius: var(--border-radius-md);
    margin-bottom: 12px;
    transition: var(--transition-fast);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.notification-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.notification-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 6px;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notification-time {
    font-size: 12px;
    color: var(--text-tertiary);
}

.notification-content {
    margin-top: 8px;
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 14px;
}

/* ====================== MODERN ADMIN PANEL ====================== */
.chat-admin-panel {
    background: var(--bg-chat);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    margin: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-normal);
    position: relative;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

.chat-admin-panel.hidden {
    display: none !important;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    position: relative;
}

.admin-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
    opacity: 0.2;
}

.admin-title {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-title i {
    color: var(--primary-color);
}

.admin-close-btn {
    background: var(--bg-hover);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.admin-close-btn:hover {
    background: var(--primary-light);
    color: var(--primary-color);
    transform: rotate(90deg);
}

.admin-section {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.admin-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.admin-section-title {
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 4px;
}

.admin-section-title i {
    color: var(--primary-color);
    font-size: 18px;
}

.member-list, .banned-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.member-item, .banned-item {
    display: flex;
    justify-content: space-between;
    padding: 14px;
    background: var(--bg-hover);
    border-radius: var(--border-radius-md);
    align-items: center;
    transition: var(--transition-normal);
    border: 1px solid var(--border-color);
}

.member-item:hover, .banned-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.member-name {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 15px;
    font-weight: 500;
}

.member-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--text-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.member-role {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    margin-left: 10px;
}

.role-creator {
    background: #ffebee;
    color: var(--danger-color);
    border: 1px solid #ffcdd2;
}

.role-admin {
    background: var(--primary-light);
    color: var(--primary-color);
    border: 1px solid #bbdefb;
}

.role-member {
    background: #e8f5e9;
    color: var(--success-color);
    border: 1px solid #c8e6c9;
}

.member-actions {
    display: flex;
    gap: 8px;
    min-width: 200px;
    justify-content: flex-end;
}

.admin-btn {
    padding: 8px 14px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
    border: none;
    white-space: nowrap;
}

.promote-btn {
    background: var(--success-color);
    color: var(--text-white);
}

.demote-btn {
    background: var(--warning-color);
    color: var(--text-white);
}

.kick-btn {
    background: var(--danger-color);
    color: var(--text-white);
}

.ban-btn {
    background: #d32f2f;
    color: var(--text-white);
}

.unban-btn {
    background: var(--primary-color);
    color: var(--text-white);
}

.admin-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.admin-btn:active {
    transform: translateY(0);
}

.invite-link-container {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
}

.invite-link-input {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background: var(--bg-hover);
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.invite-link-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(51, 144, 236, 0.2);
}

.copy-btn {
    background: var(--primary-color);
    color: var(--text-white);
    border: none;
    padding: 0 18px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    font-size: 14px;
}

.copy-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.copy-btn:active {
    transform: translateY(0);
}

.invite-link-container + p {
    margin-top: -10px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ====================== SEARCH ====================== */
.search-container {
    padding: 12px 16px;
    position: relative;
    background: var(--bg-chat);
    border-bottom: 1px solid var(--border-color);
}

.search-container input {
    width: 100%;
    padding: 10px 40px 10px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    transition: var(--transition-fast);
}

.search-container input:focus {
    border-color: var(--primary-color);
}

.search-icon {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-results {
    overflow-y: auto;
    background: var(--bg-chat);
}

.search-result {
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--bg-main);
}

.search-result:hover {
    background: var(--bg-hover);
}

.search-user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-white);
    font-size: 16px;
}

/* ====================== CREATE CHAT FORM ====================== */
.create-chat-form {
    background: var(--bg-chat);
    padding: 24px;
    border-radius: var(--border-radius-md);
    margin: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.create-chat-title {
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 20px;
}

.form-row {
    margin-bottom: 16px;
}

/* ====================== FILE MESSAGES ====================== */
.file-message, .modern-file-message {
    background: var(--bg-hover);
    border-radius: var(--border-radius-md);
    padding: 14px;
    margin-top: 8px;
    border: 1px solid var(--border-color);
}

.file-info {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.file-icon {
    font-size: 28px;
    color: var(--primary-color);
}

.file-details {
    flex: 1;
}

.file-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    word-break: break-all;
}

.file-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-size, .file-type {
    font-size: 12px;
    color: var(--text-secondary);
}

.file-preview, .image-preview {
    max-width: 280px;
    max-height: 200px;
    display: block;
    margin: 10px 0;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-sm);
    object-fit: contain;
    cursor: pointer;
    transition: var(--transition-normal);
    background: #f8f9fa;
}

.file-preview:hover, .image-preview:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.download-btn, .download-btn-modern {
    background: var(--primary-color);
    color: var(--text-white);
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition-fast);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.download-btn:hover, .download-btn-modern:hover {
    background: var(--primary-hover);
}

.download-btn:active, .download-btn-modern:active {
    transform: scale(0.98);
}

/* ====================== EMPTY STATES ====================== */
.no-chats-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    color: var(--text-secondary);
    padding: 60px 20px;
}

.no-chats-icon {
    font-size: 64px;
    margin-bottom: 20px;
    color: var(--text-tertiary);
    opacity: 0.5;
}

.no-chats-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.no-chats-text {
    max-width: 400px;
    line-height: 1.6;
    font-size: 14px;
    color: var(--text-secondary);
}

.create-first-chat {
    background: var(--primary-color);
    color: var(--text-white);
    border: none;
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 500;
    margin-top: 20px;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.create-first-chat:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.create-first-chat:active {
    transform: translateY(0);
}

.unread-badge {
    color: var(--danger-color);
    font-size: 18px;
    margin-left: 4px;
    animation: badgePulse 1.5s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

/* ====================== MOBILE MENU ====================== */
.side-menu {
    position: fixed;
    top: 0;
    left: -320px;
    width: 320px;
    height: 100%;
    background: var(--bg-chat);
    transition: left var(--transition-normal);
    z-index: 1000;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.side-menu.open {
    left: 0;
}

.side-menu .tabs {
    flex-direction: column;
    padding: 0;
    border-bottom: none;
    display: flex;
    height: 100%;
}

.side-menu .tab {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    border-left: 3px solid transparent;
    justify-content: flex-start;
    margin: 0;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    background: none;
    border-top: none;
    border-right: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.side-menu .tab:hover {
    background: var(--bg-hover);
}

.side-menu .tab.active {
    border-left: 3px solid var(--primary-color);
    background: var(--primary-light);
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
}

.side-menu .tab i {
    width: 24px;
    text-align: center;
    margin-right: 12px;
    font-size: 18px;
}

.side-menu .tab:last-child {
    border-bottom: none;
}

.logout-tab {
    color: var(--danger-color) !important;
    border-top: none !important;
    margin-top: 0 !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.logout-tab:hover {
    background: #ffebee !important;
    border-left: 3px solid var(--danger-color) !important;
}

.side-menu .tab.active.logout-tab {
    border-left: 3px solid var(--danger-color) !important;
    background: #ffebee !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--danger-color) !important;
}

.hamburger, .back-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    display: none;
    padding: 8px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-fast);
}

.hamburger:hover, .back-btn:hover {
    background: var(--bg-hover);
}

.back-btn {
    color: var(--primary-color);
    font-size: 16px;
    margin-right: 12px;
    padding: 8px 12px;
    font-weight: 500;
}

.back-btn:hover {
    background: var(--primary-light);
}

/* ====================== ADMIN TOGGLE BUTTON ====================== */
.admin-toggle {
    background: var(--primary-color);
    color: var(--text-white);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition-normal);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.admin-toggle::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--primary-hover);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.admin-toggle:hover::after {
    opacity: 1;
}

.admin-toggle:active {
    transform: scale(0.95);
    box-shadow: var(--shadow-md);
}

.admin-toggle i {
    position: relative;
    z-index: 2;
}

.admin-toggle.active {
    box-shadow: 0 0 0 3px var(--primary-light);
    transform: rotate(45deg);
    transition: all var(--transition-normal);
}

.chat-header-with-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    justify-content: space-between;
}

/* ====================== MODAL STYLES ====================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1003;
    padding: 20px;
}

.modal-content {
    background: var(--bg-chat);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.member-info {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-hover);
    border-radius: var(--border-radius-md);
}

.member-details {
    flex: 1;
}

.modal-member-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 16px;
    margin-bottom: 4px;
}

.modal-member-handle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

.modal-member-role {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary-color);
    display: inline-block;
    font-weight: 500;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-btn {
    padding: 14px 16px;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
}

.modal-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.modal-btn:active {
    transform: translateY(0);
}

.modal-btn.promote-btn {
    background: var(--success-color);
    color: white;
}

.modal-btn.demote-btn {
    background: var(--warning-color);
    color: white;
}

.modal-btn.kick-btn {
    background: var(--danger-color);
    color: white;
}

.modal-btn.ban-btn {
    background: #d32f2f;
    color: white;
}

.member-item.clickable {
    cursor: pointer;
    transition: var(--transition-fast);
}

.member-item.clickable:hover {
    background: var(--primary-light);
    transform: translateX(4px);
}

/* ====================== IMAGE MESSAGES ====================== */
.image-message {
    background: transparent;
    border: none;
    max-width: 300px;
}

.image-preview-container {
    position: relative;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    cursor: pointer;
    max-width: 400px;
    margin: 4px 0;
}

.message.user .image-preview-container {
    margin-right: auto;
    margin-left: 0;
}

.message.self .image-preview-container {
    margin-left: auto;
    margin-right: 0;
}

.message.user .image-preview {
    border-radius: 12px 12px 12px 4px;
}

.message.self .image-preview {
    border-radius: 12px 12px 4px 12px;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview-container:hover .image-overlay {
    opacity: 1;
}

.image-actions {
    display: flex;
    gap: 8px;
}

.image-action-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.image-action-btn:hover {
    background: white;
    transform: scale(1.1);
}

.file-error {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    background: var(--bg-hover);
    border-radius: var(--border-radius-md);
    font-style: italic;
}

/* ====================== DOCUMENT MESSAGES ====================== */
.document-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    max-width: 320px;
}

.message.user .document-message {
    background: rgba(255, 255, 255, 0.7);
}

.message.self .document-message {
    background: rgba(239, 253, 222, 0.8);
}

.file-icon-container {
    flex-shrink: 0;
}

.file-icon-large {
    font-size: 32px;
    color: var(--primary-color);
}

.download-btn-modern {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.download-btn-modern:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

/* ====================== IMAGE MODAL ====================== */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1004;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.image-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: var(--bg-chat);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    animation: modalSlideUp 0.3s ease;
}

.image-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-chat);
    border-bottom: 1px solid var(--border-color);
}

.image-modal-title {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 16px;
}

.image-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: var(--transition-fast);
}

.image-modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.image-modal-download {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.image-modal-download:hover {
    background: var(--primary-hover);
}

.image-modal-body {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal-img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: var(--border-radius-sm);
}

/* ====================== LOADING STATES ====================== */
.loading-state {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(51, 144, 236, 0.2);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.loading-skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-hover) 0%,
                                var(--border-color) 50%,
                                var(--bg-hover) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* ====================== OVERLAY ====================== */
.admin-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    backdrop-filter: blur(2px);
}

.admin-overlay.active {
    display: block;
}

/* ====================== UTILITIES ====================== */
.small-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ====================== CUSTOM SCROLLBAR ====================== */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ====================== RESPONSIVE DESIGN ====================== */
@media (max-width: 480px) {
    .header-logo {
        width: 48px;
        height: 48px;
        margin-right: 10px;
    }
}

@media (max-width: 768px) {
    .messages-container {
        padding-bottom: 120px !important;
        height: auto !important;
        min-height: 0;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 8px;
    }

    .chat-input {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-chat);
        border-top: 1px solid var(--border-color);
        padding: 12px 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
        z-index: 1000;
        background: rgba(255, 255, 255, 0.98);
    }

    .chat-container {
        padding-bottom: 80px;
    }

    .chat-admin-panel {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        margin: 0;
        border-radius: 0;
        z-index: 1002;
        transform: translateY(100%);
        box-shadow: none;
        border: none;
        overflow-y: auto;
        padding-bottom: 80px;
        display: block !important;
    }

    .chat-admin-panel.visible {
        transform: translateY(0);
    }

    .admin-toggle {
        width: 40px;
        height: 40px;
        font-size: 18px;
        position: relative;
        bottom: auto;
        right: auto;
        margin-left: 8px;
        flex-shrink: 0;
    }

    .chat-header-panel {
        padding: 12px 16px;
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .chat-header-with-actions {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .chat-title {
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
        min-width: 0;
    }

    .back-btn {
        margin-right: 8px;
        flex-shrink: 0;
    }

    .chat-description {
        display: none;
    }

    .admin-section {
        margin-bottom: 20px;
        padding-bottom: 16px;
    }

    .member-actions {
        flex-direction: column;
        gap: 8px;
        width: 100%;
        align-items: stretch;
    }

    .admin-btn {
        width: 100%;
        justify-content: center;
        padding: 10px;
    }

    .invite-link-container {
        flex-direction: column;
        align-items: stretch;
    }

    .copy-btn {
        width: 100%;
        height: 48px;
    }

    .hamburger, .mobile-only, .back-btn {
        display: block;
    }

    .tabs {
        display: none;
    }

    .side-menu .tabs {
        display: flex !important;
        flex-direction: column;
        padding: 0;
        border-bottom: none;
    }

    .side-menu {
        display: flex;
        flex-direction: column;
    }

    .side-menu .tabs {
        flex: 1;
        overflow-y: auto;
    }

    .side-menu.open {
        box-shadow: var(--shadow-xl);
        z-index: 1001;
    }

    .chat-header {
        padding: 10px 16px;
    }

    .chat-header h2 {
        font-size: 18px;
    }

    .status-indicator {
        font-size: 12px;
        padding: 5px 12px;
    }

    .sidebar {
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .messages-panel {
        display: none;
    }

    #directMessagesPanel.active,
    #chatMessagesPanel.active {
    display: flex;
    }

    .action-btn, .send-btn {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }

    .message-input {
        font-size: 14px;
        padding: 10px 14px;
    }

    .chat-input {
        padding: 12px 16px;
        gap: 10px;
    }

    .message {
        max-width: 80%;
        font-size: 14px;
    }

    .no-chats-message {
        padding: 40px 20px;
    }

    .no-chats-icon {
        font-size: 48px;
    }

    .no-chats-title {
        font-size: 18px;
    }

    .file-preview, .image-preview {
        max-width: 100%;
    }

    .image-preview-container {
        max-width: 300px;
    }

    .image-preview {
        max-height: 400px;
    }

    .image-action-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .document-message {
        max-width: 280px;
    }

    .modal {
        padding: 16px;
    }

    .modal-content {
        max-width: 100%;
    }

    .modal-body {
        padding: 20px;
    }

    .member-info {
        flex-direction: column;
        text-align: center;
    }

    @media (max-height: 700px) {
        .chat-input {
            padding-top: 8px;
            padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
        }

        .message-input {
            min-height: 40px;
            padding: 10px 14px;
        }

        .action-btn, .send-btn {
            width: 40px;
            height: 40px;
        }
    }

    @media (max-height: 600px) {
        .chat-header-panel {
            padding: 8px 12px;
        }

        .messages-container {
            padding: 12px 8px;
            padding-bottom: 70px;
        }

        .chat-input {
            padding: 12px;
        }
    }
}

@media (max-width: 480px) {
    .admin-toggle {
        width: 36px;
        height: 36px;
        font-size: 16px;
        margin-left: 6px;
    }

    .chat-header-panel {
        padding: 10px 12px;
        gap: 8px;
    }

    .chat-title {
        font-size: 15px;
    }

    .auth-container {
        margin: 10px;
        border-radius: var(--border-radius-md);
    }

    .auth-header {
        padding: 24px 20px;
    }

    .auth-header h1 {
        font-size: 22px;
    }

    .auth-form-container {
        padding: 20px;
    }

    .form-control {
        padding: 11px 14px;
        font-size: 14px;
    }

    .form-btn {
        padding: 12px;
        font-size: 14px;
    }

    .sidebar-header {
        padding: 14px 16px;
    }

    .chat-item, .user-item {
        padding: 10px 14px;
    }

    .chat-avatar, .user-avatar {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    .chat-name, .user-name {
        font-size: 14px;
    }

    .messages-container {
        padding: 16px 12px;
    }

    .message {
        padding: 8px 12px;
        font-size: 13px;
    }

    .create-chat-form {
        padding: 20px;
        margin: 16px;
    }

    .image-preview-container {
        max-width: 250px;
    }

    .image-preview {
        max-height: 350px;
    }
}

@media (max-width: 1200px) {
    .sidebar {
        width: 280px;
    }
}

@media (max-width: 992px) {
    .chat-main {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}

@media (max-width: 576px) {
    body {
        font-size: 14px;
    }
}

/* ====================== ACCESSIBILITY ====================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ====================== HOVER EFFECTS ====================== */
@media (hover: hover) {
    .chat-item:hover,
    .user-item:hover,
    .search-result:hover {
        transform: translateX(2px);
    }

    .action-btn:hover,
    .send-btn:hover,
    .sidebar-action:hover {
        box-shadow: var(--shadow-md);
    }

    .notification-item:hover {
        border-color: var(--primary-color);
    }
}

/* ====================== PRINT STYLES ====================== */
@media print {
    .chat-header,
    .tabs,
    .sidebar,
    .chat-input,
    .chat-actions,
    .admin-panel,
    .side-menu {
        display: none !important;
    }

    .messages-container {
        height: auto !important;
        overflow: visible !important;
    }

    .message {
        page-break-inside: avoid;
    }
}

@supports (-webkit-touch-callout: none) {
    .messages-container {
        padding-bottom: 140px !important;
    }

    .chat-input {
        padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
    }
}

/* Улучшаем скроллбар для мобильных */
.messages-container::-webkit-scrollbar {
    width: 4px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.messages-container:not(:hover)::-webkit-scrollbar-thumb {
    background: transparent;
}

.messages-container:hover::-webkit-scrollbar-thumb {
    background: var(--border-color);
}

/* Для мобильных браузеров */
@media (max-width: 768px) {
    .chat-container {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }

    html, body {
        height: 100%;
        overflow: hidden;
    }
}


 /* MOBILE CONTEXT MENU */

#mobile-context-menu {
position: fixed;
min-width: 180px;
max-width: 90vw;
background: #ffffff;
border-radius: 14px;
box-shadow: 0 8px 28px rgba(0,0,0,0.14);
padding: 8px;
z-index: 2100;
display: none;
flex-direction: column;
gap: 4px;
border: 1px solid rgba(0,0,0,0.05);
-webkit-tap-highlight-color: transparent;
animation: menuFadeIn 0.15s ease-out;
}

#mobile-context-menu .menu-btn {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 14px;
border-radius: 10px;
cursor: pointer;
font-weight: 600;
font-size: 15px;
color: var(--text-primary, #000);
background: transparent;
border: none;
text-align: left;
transition: background 0.15s ease;
}

#mobile-context-menu .menu-btn i {
width: 18px;
text-align: center;
font-size: 15px;
}

#mobile-context-menu .menu-btn:active {
transform: scale(0.985);
}

#mobile-context-menu .menu-btn:hover {
background: rgba(0,0,0,0.04);
}

#mobile-context-menu .menu-btn.delete {
color: var(--danger-color, #e53935);
}


/* Fade-in menu animation */
@keyframes menuFadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}


/* ───────────────────────────────────────────────
 *  REPLY PREVIEW BAR (above input)
 *  ─────────────────────────────────────────────── */
#reply-preview-bar {
position: fixed;
left: 12px;
right: 12px;
/* bottom set dynamically via JS */
background: #ffffff;
border-radius: 12px;
box-shadow: 0 6px 20px rgba(0,0,0,0.10);
padding: 12px 14px;
z-index: 2099;
display: none;
border: 1px solid rgba(0,0,0,0.05);
overflow: hidden;
animation: replyFadeIn 0.15s ease-out;
}

#reply-preview-bar .reply-top {
font-size: 13px;
font-weight: 700;
color: var(--text-secondary, #707579);
margin-bottom: 6px;
}

#reply-preview-bar .reply-snippet {
font-size: 14px;
color: var(--text-primary, #000);
max-height: 44px;
line-height: 1.35;
overflow: hidden;
text-overflow: ellipsis;
}

#reply-preview-bar .reply-close {
position: absolute;
top: 8px;
right: 10px;
background: none;
border: none;
font-size: 16px;
font-weight: 700;
cursor: pointer;
color: var(--text-tertiary, #aaa);
}

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


/* ───────────────────────────────────────────────
 *  INLINE REPLY BUBBLE (inside message)
 *  ─────────────────────────────────────────────── */
.message .reply-bubble {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 10px;
    border-left: 3px solid rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-secondary, #444);
}

.message .reply-bubble .reply-sender {
    font-weight: 700;
    font-size: 12px;
    color: var(--text-secondary, #666);
}

.message .reply-bubble .reply-text {
    font-size: 13px;
    color: var(--text-primary, #111);
    max-height: 38px;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message.deleted-message {
    opacity: 0.7;
}

.message.deleted-message .message-text {
    font-style: italic;
    color: var(--text-secondary) !important;
}

/* Делаем удаленные сообщения некликабельными */
.message.deleted-message {
    pointer-events: none;
}

/* Но разрешаем выделение текста для копирования */
.message.deleted-message .message-text {
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
}

/* Стили для модального окна присоединения к чату */
#joinChatModal .modal-content {
max-width: 400px;
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-hover);
    border-radius: var(--border-radius-md);
}

#joinChatModal .chat-avatar {
width: 60px;
height: 60px;
border-radius: 50%;
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
color: var(--text-white);
display: flex;
align-items: center;
justify-content: center;
font-weight: 600;
font-size: 24px;
flex-shrink: 0;
}

#joinChatModal .chat-details {
flex: 1;
}

#joinChatModal .chat-name {
font-weight: 600;
color: var(--text-primary);
font-size: 18px;
margin-bottom: 4px;
}

#joinChatModal .chat-creator {
color: var(--text-secondary);
font-size: 14px;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.join-btn {
    background: var(--success-color);
    color: var(--text-white);
    border: none;
    padding: 14px 20px;
    border-radius: var(--border-radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.join-btn:hover:not(:disabled) {
    background: #43a047;
    transform: translateY(-1px);
}

.join-btn:disabled {
    background: var(--text-tertiary);
    cursor: not-allowed;
    transform: none;
}

.cancel-btn {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 12px 20px;
    border-radius: var(--border-radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.cancel-btn:hover {
    background: var(--bg-active);
}

/* Стили для кликабельных ссылок в сообщениях */
.invite-link {
    color: var(--primary-color);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
}

.invite-link:hover {
    color: var(--primary-hover);
}

.message-text a {
    color: var(--primary-color);
    text-decoration: underline;
    word-break: break-all;
}

.message-text a:hover {
    color: var(--primary-hover);
}

/* ───────────────────────────────────────────────
 *  DESKTOP DISABLE (module is mobile-focused)
 *  ─────────────────────────────────────────────── */
@media (min-width: 769px) {
    #mobile-context-menu,
    #reply-preview-bar {
    display: none !important;
    }
}
