* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #000000 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

/* ========== АВТОРИЗАЦИЯ ========== */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 20px;
}

.auth-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.auth-box h2 {
    margin-bottom: 30px;
    text-align: center;
    color: #333;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #666;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

button {
    width: 100%;
    padding: 12px;
    background: #772056;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

button:hover {
    background: #85426b;
}

.error {
    background: #fee;
    color: #c33;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
}

.success {
    background: #e8f5e9;
    color: #4caf50;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
}

/* ========== ОСНОВНЫЕ СТИЛИ МЕССЕНДЖЕРА ========== */
.messenger-container {
    display: flex;
    height: 100vh;
    background: white;
    overflow: hidden;
}

/* ========== САЙДБАР ========== */
.sidebar {
    width: 300px;
    background: #f4f6f9;
    border-right: 1px solid #e0e4e8;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.user-info {
    padding: 20px;
    background: white;
    border-bottom: 1px solid #e0e4e8;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.user-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.avatar {
    width: 50px;
    height: 50px;
    background: #667eea;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    position: relative;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.name {
    display: block;
    font-weight: bold;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status {
    font-size: 12px;
}

.status.online {
    color: #4caf50;
}

.logout-btn {
    color: #f44336;
    text-decoration: none;
    font-size: 14px;
}

.admin-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s;
    text-decoration: none;
    color: #333;
}

.admin-btn:hover {
    background: rgba(0,0,0,0.1);
    transform: scale(1.1);
}

.admin-badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

/* ========== ПОИСК ========== */
.search-container {
    padding: 10px;
    position: relative;
    border-bottom: 1px solid #e0e4e8;
}

#search-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.search-result {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.search-result:hover {
    background: #f5f5f5;
}

.no-results {
    padding: 20px;
    text-align: center;
    color: #999;
}

.search-users {
    padding: 15px;
}

.search-users input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

/* ========== СПИСОК ПОЛЬЗОВАТЕЛЕЙ ========== */
.users-list {
    flex: 1;
    overflow-y: auto;
}

.user-item {
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: background 0.3s;
}

.user-item:hover {
    background: #e8eef5;
}

.user-item.selected {
    background: #e3f2fd;
    border-left: 3px solid #2196f3;
}

.user-item.selected .user-name {
    color: #1976d2;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: #4caf50;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    position: relative;
}

.user-avatar.online::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #4caf50;
    border-radius: 50%;
    border: 2px solid white;
}

.user-avatar.offline::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #9e9e9e;
    border-radius: 50%;
    border: 2px solid white;
}

.user-name {
    font-weight: bold;
    color: #333;
}

.user-login {
    font-size: 12px;
    color: #666;
}

.user-status {
    font-size: 11px;
}

.user-status.online {
    color: #4caf50;
}

.user-status.offline {
    color: #9e9e9e;
}

/* ========== ОБЛАСТЬ ЧАТА ========== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 20px;
    background: white;
    border-bottom: 1px solid #e0e4e8;
}

.chat-user-name {
    font-weight: bold;
    font-size: 18px;
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9f9f9;
}

.no-chat {
    text-align: center;
    color: #999;
    margin-top: 50px;
}

/* ========== СООБЩЕНИЯ ========== */
.message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
}

.my-message {
    align-items: flex-end;
}

.other-message {
    align-items: flex-start;
}

.message-text {
    max-width: 60%;
    padding: 10px 15px;
    border-radius: 10px;
    word-wrap: break-word;
}

.my-message .message-text {
    background: #667eea;
    color: white;
}

.other-message .message-text {
    background: white;
    color: #333;
    border: 1px solid #ddd;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 5px;
}

/* ========== ОБЛАСТЬ ВВОДА ========== */
.message-input-area {
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e4e8;
}

#message-form {
    position: relative;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

#message-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    min-height: 40px;
    max-height: 100px;
}

#message-input:focus {
    outline: none;
    border-color: #667eea;
}

.input-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ========== КНОПКИ ========== */
.emoji-btn, .voice-btn {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    width: 50px;
}

.emoji-btn:hover, .voice-btn:hover {
    background: #e0e0e0;
    transform: scale(1.02);
}

.notify-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s;
}

.notify-btn:hover {
    background: rgba(0,0,0,0.1);
    transform: scale(1.1);
}

.file-label {
    cursor: pointer;
    font-size: 18px;
    padding: 8px 12px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 8px;
    transition: all 0.2s;
}

.file-label:hover {
    background: #e0e0e0;
}

#send-message {
    margin: 0;
    padding: 8px 20px;
    width: auto;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

#send-message:hover {
    background: #5a67d8;
    transform: scale(1.02);
}

#send-message:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* ========== ЭМОДЗИ ПИКЕР ========== */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 12px;
    z-index: 1000;
    width: 440px;
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.emoji-list {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.emoji {
    font-size: 24px;
    cursor: pointer;
    text-align: center;
    padding: 6px;
    transition: all 0.1s;
    border-radius: 8px;
}

.emoji:hover {
    transform: scale(1.2);
    background: #f0f0f0;
}

/* ========== ПРЕВЬЮ ФАЙЛОВ ========== */
.image-preview, .file-preview {
    position: relative;
    display: inline-block;
    margin-bottom: 10px;
    padding: 8px;
    background: #f0f0f0;
    border-radius: 10px;
    animation: fadeIn 0.3s ease;
}

.image-preview img {
    border-radius: 8px;
    max-width: 100px;
    max-height: 100px;
}

#remove-preview {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

#remove-preview:hover {
    background: #cc0000;
    transform: scale(1.1);
}

/* ========== ФАЙЛЫ В СООБЩЕНИЯХ ========== */
.message-image {
    max-width: 250px;
    max-height: 250px;
    border-radius: 12px;
    cursor: pointer;
    margin-top: 8px;
    border: 1px solid #ddd;
    transition: transform 0.2s;
}

.message-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.message-file {
    margin-top: 8px;
}

.file-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #f0f0f0;
    border-radius: 20px;
    text-decoration: none;
    color: #333;
    font-size: 12px;
    transition: all 0.2s;
}

.file-link:hover {
    background: #e0e0e0;
    transform: translateX(2px);
}

.message-audio {
    margin-top: 8px;
}

.message-audio audio {
    max-width: 250px;
    height: 42px;
    border-radius: 25px;
}

.file-name {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
}

/* ========== ЗАПИСЬ ГОЛОСА ========== */
#voice-recording {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #ff4444;
    color: white;
    padding: 12px;
    text-align: center;
    border-radius: 10px 10px 0 0;
    animation: pulse 1s infinite;
    z-index: 100;
}

/* ========== МОДАЛЬНОЕ ОКНО ========== */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.image-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 10px;
}

/* ========== АНИМАЦИИ ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

.loading-messages {
    text-align: center;
    padding: 50px;
    color: #999;
    animation: pulse 1.5s ease-in-out infinite;
}

/* ========== ПРОКРУТКА ========== */
.emoji-picker::-webkit-scrollbar {
    width: 6px;
}

.emoji-picker::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.emoji-picker::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

/* ========== КНОПКА МЕНЮ ДЛЯ МОБИЛЬНЫХ ========== */
.menu-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1001;
    background: #667eea;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    border: none;
    font-size: 24px;
    transition: all 0.3s;
}

.menu-toggle:hover {
    transform: scale(1.05);
    background: #5a67d8;
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 768px) {
	.messenger-container {
    display: flex;
    height: 80%;
    background: white;
    overflow: hidden;
}
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 1000;
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .chat-area {
        width: 100%;
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .emoji-picker {
        width: calc(100% - 20px);
        left: 10px;
        right: 10px;
        max-width: 350px;
    }
    
    .emoji-list {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .message-text {
        max-width: 85%;
        font-size: 14px;
    }
    
    .input-wrapper {
        flex-wrap: wrap;
    }
    
    .input-buttons {
        flex-wrap: wrap;
    }
    
    .user-info {
        flex-direction: column;
        text-align: center;
    }
    
    .user-actions {
        justify-content: center;
        width: 100%;
    }
    
    .search-container,
    .search-users {
        padding: 8px;
    }
    
    #search-input,
    .search-users input {
        padding: 8px;
        font-size: 12px;
    }
    
    .search-result {
        padding: 8px;
        font-size: 12px;
    }
    
    .user-status {
        font-size: 9px;
    }
    
    .user-avatar.online::after,
    .user-avatar.offline::after {
        width: 10px;
        height: 10px;
        bottom: -1px;
        right: -1px;
    }
}

@media (max-width: 480px) {
	.messenger-container {
    display: flex;
    height: 80%;
    background: white;
    overflow: hidden;
}
    .auth-box {
        padding: 20px;
        margin: 20px;
    }
    
    .auth-box h2 {
        font-size: 20px;
        margin-bottom: 20px;
    }
    
    .form-group input {
        padding: 8px;
        font-size: 14px;
    }
    
    button {
        padding: 10px;
        font-size: 14px;
    }
    
    .sidebar {
        width: 260px;
    }
    
    .user-item {
        padding: 12px;
        gap: 10px;
    }
    
    .user-avatar {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }
    
    .user-name {
        font-size: 14px;
    }
    
    .user-login {
        font-size: 10px;
    }
    
    .chat-header {
        padding: 15px;
    }
    
    .chat-user-name {
        font-size: 16px;
    }
    
    .messages-area {
        padding: 15px;
    }
    
    .message-text {
        max-width: 90%;
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .message-time {
        font-size: 9px;
    }
    
    .message-input-area {
        padding: 12px;
    }
    
    .emoji-btn, .voice-btn, .file-label {
        padding: 6px 10px;
        font-size: 16px;
        width: 40px;
    }
    
    #send-message {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    #message-input {
        padding: 8px;
        font-size: 13px;
    }
    
    .emoji-picker {
        width: calc(100% - 20px);
        max-width: 300px;
        max-height: 180px;
    }
    
    .emoji {
        font-size: 18px;
        padding: 4px;
    }
    
    .message-image {
        max-width: 150px;
        max-height: 150px;
    }
    
    .message-audio audio {
        max-width: 150px;
    }
    
    .file-link {
        padding: 6px 10px;
        font-size: 11px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }
    
    .emoji-picker {
        width: 400px;
    }
    
    .emoji-list {
        grid-template-columns: repeat(8, 1fr);
    }
    
    .message-text {
        max-width: 70%;
    }
}

@media (min-width: 1200px) {
    .sidebar {
        width: 350px;
    }
    
    .emoji-picker {
        width: 500px;
        max-height: 300px;
    }
    
    .emoji-list {
        grid-template-columns: repeat(10, 1fr);
    }
    
    .message-text {
        max-width: 50%;
    }
}

/* Улучшение для touch-экранов */
@media (hover: none) and (pointer: coarse) {
    .user-item,
    .emoji,
    button,
    .file-label,
    .voice-btn,
    .emoji-btn {
        cursor: default;
    }
    
    button:active,
    .user-item:active,
    .emoji:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}
/* ========== ИСПРАВЛЕНИЕ ДЛЯ ФОРМЫ ОТПРАВКИ ========== */
.message-input-area {
    display: block !important;
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e4e8;
    position: relative;
}

#message-form {
    position: relative;
    display: flex;
    flex-direction: column;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

#message-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    min-height: 40px;
    max-height: 100px;
    background: white;
}

#message-input:focus {
    outline: none;
    border-color: #667eea;
}

.input-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.emoji-btn, .voice-btn {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    width: 50px;
}

.file-label {
    cursor: pointer;
    font-size: 18px;
    padding: 8px 12px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 8px;
    transition: all 0.2s;
}

#send-message {
    margin: 0;
    padding: 8px 20px;
    width: auto;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

#send-message:hover {
    background: #5a67d8;
    transform: scale(1.02);
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .message-input-area {
        padding: 12px;
    }
    
    .emoji-btn, .voice-btn, .file-label {
        padding: 6px 10px;
        font-size: 16px;
        width: 40px;
    }
    
    #send-message {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    #message-input {
        padding: 8px;
        font-size: 13px;
    }
}