* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* АВТОРИЗАЦИЯ */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: 32px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

.logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.logo h1 {
    font-size: 28px;
    color: #1a1a2e;
}

.form input {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 60px;
    font-size: 16px;
}

.form input:focus {
    outline: none;
    border-color: #667eea;
}

.form button {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 60px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.error {
    color: #ef4444;
    font-size: 14px;
    margin-top: 12px;
    text-align: center;
}

/* МЕССЕНДЖЕР */
.messenger {
    display: flex;
    height: 100vh;
    width: 100%;
    background: white;
    overflow: hidden;
}

/* Панель контактов */
.contacts-panel {
    width: 340px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.contacts-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.contacts-header h2 {
    font-size: 20px;
    color: #1e293b;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
}

.icon-btn:hover {
    background: #e2e8f0;
}

/* Кто я */
.my-identity {
    padding: 10px 20px;
    background: #eef2ff;
    font-size: 14px;
    color: #1e293b;
    border-bottom: 1px solid #e2e8f0;
}

.my-identity strong {
    color: #667eea;
}

.search-box {
    padding: 12px 20px;
    background: #f8fafc;
}

.search-box input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 30px;
    font-size: 14px;
    background: white;
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.contacts-count {
    font-size: 12px;
    color: #64748b;
    padding: 10px 20px;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    border-bottom: 1px solid #e2e8f0;
    background: white;
}

.contact-item:hover {
    background: #f1f5f9;
}

.contact-item.active {
    background: #eef2ff;
    border-left: 4px solid #667eea;
}

.contact-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    margin-right: 14px;
    flex-shrink: 0;
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.online-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
}

.offline-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    display: inline-block;
}

.contact-last-message {
    font-size: 13px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-time {
    font-size: 11px;
    color: #94a3b8;
    flex-shrink: 0;
}

.unread-badge {
    background: #ef4444;
    color: white;
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
}

/* Область чата */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    min-width: 0;
}

.chat-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-content {
    text-align: center;
    color: #94a3b8;
}

.placeholder-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.contact-name {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.contact-status {
    font-size: 13px;
}

.contact-status.online {
    color: #22c55e;
}

.contact-status.offline {
    color: #94a3b8;
}

.close-chat {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #94a3b8;
    padding: 4px 8px;
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
}

.messages-list {
    display: flex;
    flex-direction: column;
}

.message {
    margin-bottom: 16px;
    display: flex;
}

.message.outgoing {
    justify-content: flex-end;
}

.message.incoming {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 10px 16px;
    border-radius: 20px;
    word-wrap: break-word;
}

.message.outgoing .message-bubble {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.incoming .message-bubble {
    background: white;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message-time {
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.7;
}

.message.outgoing .message-time {
    text-align: right;
    color: #94a3b8;
}

.message-input-area {
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    background: white;
}

.message-input-area textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    max-height: 100px;
}

.message-input-area textarea:focus {
    outline: none;
    border-color: #667eea;
}

.send-btn {
    width: 44px;
    height: 44px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
}

.send-btn:hover {
    background: #5a67d8;
}

.loading-spinner {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
}

/* МОБИЛЬНАЯ ВЕРСИЯ */
@media (max-width: 768px) {
    .messenger {
        flex-direction: column;
    }
    
    .contacts-panel {
        width: 100%;
        height: 45%;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .chat-panel {
        width: 100%;
        height: 55%;
    }
    
    .contact-item {
        padding: 10px 16px;
    }
    
    .contact-avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
        margin-right: 12px;
    }
    
    .contact-name {
        font-size: 14px;
    }
    
    .contact-last-message {
        font-size: 12px;
    }
    
    .message-bubble {
        max-width: 85%;
        font-size: 14px;
    }
    
    .chat-header {
        padding: 12px 16px;
    }
    
    .messages-area {
        padding: 12px;
    }
    
    .message-input-area {
        padding: 12px;
    }
    
    .message-input-area textarea {
        font-size: 16px;
    }
}