* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --secondary-color: #764ba2;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --bg-color: #f7fafc;
    --text-color: #2d3748;
    --border-color: #e2e8f0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-color);
}

/* Анимации */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ============================================ */
/* АВТОРИЗАЦИЯ */
/* ============================================ */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-box {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    animation: fadeIn 0.5s ease-out;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    color: #333;
    font-size: 2em;
    margin-bottom: 10px;
}

.auth-subtitle {
    color: #666;
    font-size: 14px;
}

.auth-tabs {
    display: flex;
    margin-bottom: 30px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--primary-color);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: white;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s;
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.tab-btn:hover:not(.active) {
    background: #f0f0f0;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-size: 14px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    transition: border-color 0.3s;
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: none;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    padding: 14px;
    background: #f0f0f0;
    color: #333;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.error-message {
    color: var(--danger-color);
    margin-top: 10px;
    text-align: center;
    font-size: 14px;
    min-height: 20px;
}

/* ============================================ */
/* ДАШБОРД */
/* ============================================ */
.dashboard-container {
    display: flex;
    height: 100vh;
    background: white;
    overflow: hidden;
}

/* ============================================ */
/* БОКОВАЯ ПАНЕЛЬ */
/* ============================================ */
.sidebar {
    width: 380px;
    min-width: 250px;
    max-width: 600px;
    background: #f8f9fa;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: none;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: bold;
    color: white;
    border: 2px solid rgba(255,255,255,0.3);
    flex-shrink: 0;
}

.user-name {
    font-weight: 600;
    font-size: 16px;
}

.user-status {
    font-size: 12px;
    opacity: 0.8;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.icon-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

.logout-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    white-space: nowrap;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* ============================================ */
/* ПОИСК КОНТАКТОВ */
/* ============================================ */
.search-box {
    padding: 15px;
}

.search-box input {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 14px;
    transition: border-color 0.3s;
    background: white;
    outline: none;
}

.search-box input:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: none;
}

/* ============================================ */
/* СПИСОК КОНТАКТОВ */
/* ============================================ */
.contacts-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    gap: 12px;
    margin-bottom: 2px;
    border: 1px solid transparent;
    background: white;
}

.contact-item:hover {
    background: #f0f0f0;
    border-color: #e0e0e0;
    transform: translateX(2px);
}

.contact-item.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.contact-item.active:hover {
    transform: none;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.contact-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: bold;
    position: relative;
    flex-shrink: 0;
    border: 2px solid transparent;
}

.contact-item.active .contact-avatar {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
}

.online-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--success-color);
    border: 2px solid white;
    position: absolute;
    bottom: 0;
    right: 0;
}

.contact-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.contact-name {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-last-message {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-item.active .contact-last-message {
    color: rgba(255,255,255,0.8);
}

.unread-badge {
    background: var(--primary-color);
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.contact-item.active .unread-badge {
    background: rgba(255,255,255,0.3);
    color: white;
}

/* ============================================ */
/* КНОПКА ДОБАВЛЕНИЯ КОНТАКТА */
/* ============================================ */
.add-contact-btn-container {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.add-contact-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
}

.add-contact-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* ============================================ */
/* РАЗДЕЛИТЕЛЬ САЙДБАРА */
/* ============================================ */
.resize-handle {
    width: 4px;
    background: transparent;
    cursor: col-resize;
    transition: background 0.2s;
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.resize-handle:hover {
    background: #667eea;
}

.resize-handle.active {
    background: #667eea;
}

.resize-handle::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -4px;
    right: -4px;
    cursor: col-resize;
}

/* ============================================ */
/* КНОПКА НАЗАД (МОБИЛЬНАЯ) */
/* ============================================ */
.back-btn {
    display: none;
    padding: 12px 20px;
    background: white;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    color: #667eea;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.2s;
}

.back-btn:hover {
    background: #f5f5f5;
}

/* ============================================ */
/* ОБЛАСТЬ ЧАТА */
/* ============================================ */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    min-width: 0;
}

.chat-header {
    padding: 10px 20px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    z-index: 10;
    min-height: 60px;
}

/* Кнопка назад в стиле Telegram */
.back-btn-telegram {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    color: #667eea;
    font-size: 24px;
}

.back-btn-telegram:hover {
    background: #f0f0f0;
}

.back-btn-telegram:active {
    background: #e0e0e0;
    transform: scale(0.95);
}

.back-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-header-info h3 {
    font-size: 18px;
    margin-bottom: 4px;
    font-weight: 600;
}

.chat-header-info small {
    color: #666;
    font-size: 13px;
    transition: all 0.3s;
}

/* Удаляем старую кнопку назад */
.back-btn {
    display: none;
}

/* ============================================ */
/* СООБЩЕНИЯ */
/* ============================================ */
.chat-messages {
    flex: 1;
    padding: 15px 25px;
    overflow-y: auto;
    background: #e8eaed;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.message {
    max-width: 65%;
    padding: 8px 14px;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
    animation: fadeIn 0.2s ease-out;
    line-height: 1.4;
    font-size: 16px;
    margin: 1px 0;
    letter-spacing: 0.2px;
}

.message.sent {
    background: #667eea;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    margin-left: 35%;
    box-shadow: none;
}

.message.received {
    background: white;
    color: #1a1a1a;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    margin-right: 35%;
    box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

.message-text {
    font-size: 16px;
    line-height: 1.45;
    word-break: break-word;
    letter-spacing: 0.2px;
    margin-bottom: 2px;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 2px;
}

.message-time {
    font-size: 12px;
    opacity: 0.7;
}

.message-status {
    font-size: 14px;
    opacity: 0.9;
    margin-left: 2px;
}

.message.sent .message-status {
    color: rgba(255, 255, 255, 0.9);
}

/* Поле ввода */
.chat-input {
    padding: 12px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 16px;
    transition: border-color 0.3s;
    background: #f0f2f5;
    min-width: 0;
    outline: none;
}

.chat-input input:focus {
    border-color: #667eea;
    background: white;
    outline: none;
    box-shadow: none;
}

.chat-input input::placeholder {
    color: #999;
    font-size: 15px;
}

.send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 22px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    background: #5a67d8;
}

/* ============================================ */
/* ПОЛЕ ВВОДА - ТОЖЕ БОЛЬШЕ */
/* ============================================ */
.chat-input {
    padding: 18px 24px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 14px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    padding: 20px 28px;
    border: 2px solid #e0e0e0;
    border-radius: 35px;
    font-size: 22px;
    transition: border-color 0.3s;
    background: #f0f2f5;
    min-width: 0;
    outline: none;
}

.chat-input input:focus {
    border-color: #667eea;
    background: white;
    outline: none;
    box-shadow: none;
}

.chat-input input::placeholder {
    color: #999;
    font-size: 20px;
}

.send-btn {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 28px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    background: #5a67d8;
}

/* ============================================ */
/* ПОЛЕ ВВОДА */
/* ============================================ */
.chat-input {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 12px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    padding: 18px 24px;
    border: 2px solid #e0e0e0;
    border-radius: 30px;
    font-size: 20px;
    transition: border-color 0.3s;
    background: #f0f2f5;
    min-width: 0;
    outline: none;
}

.chat-input input:focus {
    border-color: #667eea;
    background: white;
    outline: none;
    box-shadow: none;
}

.chat-input input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
    border-color: #e0e0e0;
}

.chat-input input::placeholder {
    color: #999;
    font-size: 18px;
}

.send-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 26px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    background: #5a67d8;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #ccc;
}

/* ============================================ */
/* ЭКРАН ПРИВЕТСТВИЯ */
/* ============================================ */
.no-chat-selected {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.welcome-screen {
    text-align: center;
    padding: 40px;
    max-width: 500px;
}

.welcome-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.welcome-screen h2 {
    font-size: 24px;
    color: #333;
    margin-bottom: 10px;
}

.welcome-screen p {
    color: #666;
    margin-bottom: 30px;
    font-size: 16px;
    line-height: 1.5;
}

.start-chat-btn {
    padding: 16px 32px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 15px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    margin: 20px 0;
    transition: all 0.3s;
}

.start-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

/* ============================================ */
/* МОДАЛЬНОЕ ОКНО ПОИСКА */
/* ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
    backdrop-filter: blur(3px);
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.modal-close:hover {
    background: rgba(255,255,255,0.4);
    transform: rotate(90deg);
}

.modal-search {
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 15px;
    font-size: 18px;
    z-index: 1;
}

#globalSearchInput {
    width: 100%;
    padding: 14px 20px 14px 45px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    transition: border-color 0.3s;
    outline: none;
}

#globalSearchInput:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: none;
}

.search-hints {
    margin-top: 8px;
    font-size: 12px;
    color: #999;
}

.search-results-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px 25px;
}

.search-results-header {
    padding: 12px 0;
    font-weight: 600;
    color: #666;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-search-card {
    display: flex;
    align-items: center;
    padding: 14px;
    border-radius: 12px;
    margin-bottom: 8px;
    transition: all 0.3s;
    background: #f8f9fa;
    gap: 14px;
    border: 1px solid transparent;
}

.user-search-card:hover {
    background: #e9ecef;
    border-color: #e0e0e0;
    transform: translateX(3px);
}

.user-search-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    position: relative;
    flex-shrink: 0;
}

.online-indicator-mini {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #48bb78;
    border: 2px solid white;
    position: absolute;
    bottom: 0;
    right: 0;
}

.user-search-info {
    flex: 1;
    min-width: 0;
}

.user-search-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 3px;
}

.user-search-email {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.add-user-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    white-space: nowrap;
}

.add-user-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* ============================================ */
/* СКРОЛЛБАР */
/* ============================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #c4c4c4;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* Кнопка прикрепления */
.attach-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #f0f2f5;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.attach-btn:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

/* Просмотрщик фото */
.image-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.image-viewer img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 10px;
}

/* Фото в сообщениях */
.message-image {
    transition: transform 0.2s;
}

.message-image:hover {
    transform: scale(1.02);
}

/* ============================================ */
/* АДАПТИВНОСТЬ */
/* ============================================ */
@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
        position: relative;
    }
    
    .sidebar {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        height: 100vh;
        display: flex;
    }
    
    .resize-handle {
        display: none;
    }
    
    .chat-area {
        display: none;
        height: 100vh;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 200;
        background: white;
    }
    
    /* Показываем кнопку назад в стиле Telegram */
    .back-btn-telegram {
        display: flex;
    }
    
    /* Убираем старую кнопку назад */
    .back-btn {
        display: none;
    }
    
    .chat-header {
        padding: 8px 15px;
        gap: 8px;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .message {
        max-width: 85%;
        font-size: 18px;
        padding: 10px 14px;
    }
    
    .message-text {
        font-size: 18px;
    }
    
    .message.sent {
        margin-left: 15%;
    }
    
    .message.received {
        margin-right: 15%;
    }
    
    .chat-input {
        padding: 12px 15px;
    }
    
    .chat-input input {
        padding: 16px 20px;
        font-size: 18px;
    }
    
    .send-btn {
        width: 50px;
        height: 50px;
        font-size: 22px;
    }
    
    .auth-box {
        margin: 10px;
        padding: 25px;
    }
    
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    .sidebar-header {
        padding: 15px;
    }
    
    .user-name {
        font-size: 14px;
    }
    
    .message {
        font-size: 17px;
        padding: 8px 12px;
    }
    
    .message-text {
        font-size: 17px;
    }
    
    .chat-input input {
        padding: 14px 18px;
        font-size: 17px;
    }
    
    .send-btn {
        width: 46px;
        height: 46px;
        font-size: 20px;
    }
}

/* Ответ на сообщение */
.reply-block {
    background: rgba(0,0,0,0.05);
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    border-left: 3px solid #667eea;
    cursor: pointer;
}

.reply-block:hover {
    background: rgba(0,0,0,0.1);
}

.reply-name {
    font-size: 14px;
    color: #667eea;
    font-weight: 600;
}

.reply-text {
    font-size: 13px;
    color: #666;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Превью ответа */
.reply-preview {
    padding: 10px 20px;
    background: #f0f4ff;
    border-bottom: 1px solid #d0d8f0;
}

/* Контекстное меню */
.context-menu {
    animation: fadeIn 0.2s ease-out;
}

.context-item {
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    transition: background 0.2s;
    white-space: nowrap;
}

.context-item:hover {
    background: #f0f0f0;
}

/* Удаленное сообщение */
.deleted-message {
    font-style: italic;
    opacity: 0.6;
    font-size: 16px;
}

/* Кнопки действий при наведении */
.message-action-btn {
    display: none;
    position: absolute;
    top: -10px;
    right: 5px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 10;
}

.message:hover .message-action-btn,
.message.sent:hover .message-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

.message.received .message-action-btn {
    right: auto;
    left: 5px;
}

/* Кнопка создания группы */
.add-group-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    margin-top: 8px;
}

.add-group-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.4);
}

/* Смайлики */
.emoji-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 10px;
    transition: transform 0.2s;
}

.emoji-btn:hover {
    transform: scale(1.2);
}

.emoji-panel {
    flex-wrap: wrap;
    gap: 5px;
    padding: 10px;
    background: white;
    border-top: 1px solid #e0e0e0;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-item {
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: background 0.2s;
}

.emoji-item:hover {
    background: #f0f0f0;
    transform: scale(1.2);
}

/* Кнопка смайликов */
.emoji-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #f0f2f5;
    border: none;
    cursor: pointer;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.emoji-btn:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

/* Панель смайликов */
.emoji-panel {
    display: none;
    background: white;
    border-top: 1px solid #e0e0e0;
    padding: 10px;
    max-height: 250px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.emoji-item {
    font-size: 28px;
    cursor: pointer;
    padding: 8px;
    text-align: center;
    border-radius: 8px;
    transition: background 0.15s;
    user-select: none;
}

.emoji-item:hover {
    background: #e8eaed;
}

.emoji-item:active {
    background: #d0d4d9;
    transform: scale(0.95);
}

/* Для мобильных */
@media (max-width: 768px) {
    .emoji-panel {
        grid-template-columns: repeat(6, 1fr);
        max-height: 200px;
        padding: 8px;
        gap: 2px;
    }
    
    .emoji-item {
        font-size: 24px;
        padding: 6px;
    }
    
    .emoji-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

@media (max-width: 768px) {
    .chat-input {
        padding: 10px 12px;
        gap: 6px;
    }
    
    .attach-btn,
    .emoji-btn {
        width: 38px;
        height: 38px;
        font-size: 18px;
        flex-shrink: 0;
    }
    
    .chat-input input {
        padding: 12px 16px;
        font-size: 16px;
        flex: 1;
        min-width: 0;
    }
    
    .send-btn {
        width: 42px;
        height: 42px;
        font-size: 20px;
        flex-shrink: 0;
    }
    
    .emoji-panel {
        grid-template-columns: repeat(6, 1fr);
        max-height: 180px;
        gap: 2px;
        padding: 6px;
    }
    
    .emoji-item {
        font-size: 22px;
        padding: 5px;
    }
}

/* Просмотрщик фото */
.image-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.image-viewer img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 10px;
}

@media (max-width: 768px) {
    .msg-text img {
        max-width: 200px !important;
        max-height: 250px !important;
    }
    
    .image-viewer img {
        max-width: 95%;
        max-height: 80%;
    }
}

@media (max-width: 768px) {
    .group-sidebar { display: none; }
    .resize-handle { display: none; }
    .mobile-back { display: flex; align-items: center; gap: 10px; padding: 10px 15px; background: white; border-bottom: 1px solid #e0e0e0; }
    .mobile-back a { color: #667eea; text-decoration: none; font-size: 16px; font-weight: 500; }
    .group-chat-messages { padding: 15px; }
    .group-chat-input { padding: 10px; gap: 5px; }
    .group-chat-input input { padding: 12px 16px; font-size: 16px; }
    .attach-btn, .emoji-btn { width: 38px; height: 38px; font-size: 18px; }
    .send-btn { width: 40px; height: 40px; font-size: 20px; }
    .emoji-panel { grid-template-columns: repeat(6, 1fr); max-height: 180px; gap: 2px; padding: 6px; }
    .emoji-item { font-size: 22px; padding: 5px; }
    
    /* Фото в сообщениях */
    .msg-text img {
        max-width: 200px !important;
        max-height: 250px !important;
    }
    
    /* Просмотрщик фото */
    .image-viewer img {
        max-width: 95%;
        max-height: 80%;
    }
}

.chat-messages,
.group-chat-messages {
    background: linear-gradient(135deg, 
        rgba(102, 126, 234, 0.08) 0%, 
        rgba(118, 75, 162, 0.06) 30%, 
        rgba(102, 126, 234, 0.04) 60%, 
        rgba(118, 75, 162, 0.08) 100%
    ) !important;
    background-attachment: fixed !important;
    background-color: #f5f0f8 !important;
}

/* Контекстное меню */
.ctx-menu {
    animation: fadeIn 0.15s ease-out;
}

.ctx-item {
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    white-space: nowrap;
    transition: background 0.15s;
}

.ctx-item:hover {
    background: #f0f0f0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}