/* Общие сбросы и цвета */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', sans-serif; }
body { background-color: #0f172a; color: #e2e8f0; height: 100dvh; overflow: hidden; display: flex; align-items: center; justify-content: center; }

/* Кнопки и инпуты */
button { cursor: pointer; border: none; background: none; color: #94a3b8; transition: 0.2s; }
button:hover { color: #60a5fa; }
.btn-primary { background: #3b82f6; color: white; padding: 10px 15px; border-radius: 8px; font-weight: bold; width: 100%; margin-top: 10px; }
.btn-primary:hover { background: #2563eb; color: white; }
.btn-secondary { background: #334155; color: #e2e8f0; padding: 8px; border-radius: 8px; width: 100%; font-size: 14px; }
.btn-danger { background: #ef4444; color: white; padding: 10px; border-radius: 8px; width: 100%; font-weight: bold; }
.btn-danger:hover { background: #dc2626; }

input[type="text"], input[type="password"], textarea { width: 100%; padding: 10px; margin-bottom: 10px; background: #1e293b; color: #f8fafc; border: 1px solid #334155; border-radius: 8px; outline: none; resize: none; }
input:focus, textarea:focus { border-color: #3b82f6; }

/* ЭКРАН АВТОРИЗАЦИИ */
#auth-screen { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background-color: #0f172a; }
.auth-box { background: #1e293b; padding: 30px; border-radius: 16px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); width: 320px; text-align: center; border: 1px solid #334155; }
.auth-box h2 { margin-bottom: 20px; color: #f8fafc; }
.file-input-wrapper { position: relative; overflow: hidden; }
.file-input-wrapper input[type="file"] { position: absolute; left: 0; top: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.error-text { color: #f87171; font-size: 14px; margin-top: 10px; height: 20px; }

/* АВАТАРКИ */
img { background-color: #1e293b; color: transparent; }
.avatar { width: 45px; height: 45px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 2px solid transparent; transition: 0.2s; }
.avatar:hover { border-color: #3b82f6; }
.avatar-small { width: 35px; height: 35px; border-radius: 50%; object-fit: cover; align-self: flex-end; }
.avatar-large { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; border: 3px solid #334155; }
.clickable-avatar { cursor: pointer; transition: 0.2s; }
.clickable-avatar:hover { transform: scale(1.1); }

/* ГЛАВНЫЙ ЭКРАН */
.app-container { display: flex; width: 100%; max-width: 1200px; height: 100dvh; background: #0f172a; box-shadow: 0 0 20px rgba(0,0,0,0.5); }
.hidden { display: none !important; }
.text-center { text-align: center; }

/* ЛЕВАЯ ПАНЕЛЬ */
.sidebar { width: 320px; background: #1e293b; border-right: 1px solid #334155; display: flex; flex-direction: column; }
.my-profile { padding: 15px; background: #1e293b; border-bottom: 1px solid #334155; display: flex; align-items: center; gap: 10px; position: relative; }
#my-name { font-weight: bold; flex-grow: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-actions { display: flex; gap: 8px; }
.profile-actions button { position: relative; font-size: 16px; padding: 5px; }

/* Бейджик для заявок */
.badge { position: absolute; top: -5px; right: -5px; background: #ef4444; color: white; font-size: 10px; padding: 2px 5px; border-radius: 10px; font-weight: bold; }

/* Вкладки Чаты/Контакты */
.sidebar-tabs { display: flex; border-bottom: 1px solid #334155; }
.sidebar-tabs button { flex: 1; padding: 12px; font-weight: bold; color: #94a3b8; border-bottom: 2px solid transparent; border-radius: 0; }
.sidebar-tabs button.active { color: #3b82f6; border-bottom-color: #3b82f6; background: rgba(59, 130, 246, 0.1); }

.list-container { overflow-y: auto; flex-grow: 1; }
.list-container::-webkit-scrollbar { width: 6px; }
.list-container::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

/* Элементы списков */
.list-item { display: flex; align-items: center; padding: 12px 15px; gap: 15px; cursor: pointer; border-bottom: 1px solid #0f172a; transition: 0.2s; }
.list-item:hover { background: #334155; }
.list-item.active { background: #0f172a; border-left: 4px solid #3b82f6; }
.item-info { flex-grow: 1; overflow: hidden; }
.item-info h4 { font-size: 15px; color: #f8fafc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-info p { font-size: 13px; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ПРАВАЯ ПАНЕЛЬ (Чат) */
.chat-area { flex-grow: 1; display: flex; flex-direction: column; background: #0f172a; position: relative; }
.empty-state { display: flex; align-items: center; justify-content: center; height: 100%; color: #64748b; font-size: 16px; text-align: center; padding: 20px; }
.chat-header { padding: 15px 20px; border-bottom: 1px solid #334155; display: flex; align-items: center; gap: 15px; background: #1e293b; }
.mobile-only { display: none; font-size: 20px; }

.messages-container { flex-grow: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 15px; background: #0b1120; }
.messages-container::-webkit-scrollbar { width: 6px; }
.messages-container::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.message { display: flex; gap: 10px; max-width: 80%; }
.message.incoming { align-self: flex-start; }
.message.outgoing { align-self: flex-end; flex-direction: row-reverse; }
.message-content { display: flex; flex-direction: column; gap: 3px; }
.sender-name { font-size: 12px; color: #94a3b8; margin-left: 5px; }
.outgoing .sender-name { display: none; }

.bubble { padding: 10px 15px; border-radius: 16px; font-size: 15px; line-height: 1.4; word-break: break-word; }
.incoming .bubble { background: #1e293b; border-bottom-left-radius: 4px; border: 1px solid #334155; }
.outgoing .bubble { background: #2563eb; color: white; border-bottom-right-radius: 4px; }
.time { font-size: 11px; color: #64748b; align-self: flex-end; margin-top: 2px; }

.message-image { max-width: 250px; min-height: 150px; min-width: 200px; border-radius: 8px; margin-top: 5px; display: block; cursor: pointer; border: 1px solid #334155; object-fit: cover; }
.message-sticker { width: 120px; height: 120px; object-fit: contain; }

/* ПАНЕЛЬ ВВОДА И СТИКЕРЫ */
.sticker-panel { position: absolute; bottom: 70px; left: 20px; right: 20px; background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 15px; display: flex; gap: 10px; flex-wrap: wrap; box-shadow: 0 -5px 20px rgba(0,0,0,0.5); z-index: 5; max-height: 200px; overflow-y: auto; }
.sticker-btn { width: 60px; height: 60px; cursor: pointer; transition: transform 0.1s; border-radius: 8px; padding: 5px; background-color: #0f172a; }
.sticker-btn:hover { background: #334155; transform: scale(1.1); }

.input-area { padding: 15px 20px; background: #1e293b; border-top: 1px solid #334155; display: flex; align-items: center; gap: 15px; }
.input-area button { font-size: 20px; padding: 5px; }
#send-btn { color: #3b82f6; }
#message-input { flex-grow: 1; border: none; background: #0f172a; color: #e2e8f0; border-radius: 20px; padding: 12px 20px; font-size: 15px; outline: none; border: 1px solid #334155; }

/* МОДАЛЬНЫЕ ОКНА */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-box { background: #1e293b; padding: 25px; border-radius: 12px; width: 90%; max-width: 400px; border: 1px solid #334155; position: relative; box-shadow: 0 10px 30px rgba(0,0,0,0.8); }
.close-modal { position: absolute; top: 15px; right: 15px; font-size: 20px; color: #64748b; }
.close-modal:hover { color: #f87171; }
.bio-text { background: #0f172a; padding: 15px; border-radius: 8px; font-size: 14px; color: #cbd5e1; border: 1px solid #334155; word-wrap: break-word; }

/* Списки внутри модалок (поиск, участники группы) */
.modal-list { margin-top: 15px; max-height: 250px; overflow-y: auto; background: #0f172a; border-radius: 8px; border: 1px solid #334155; }
.modal-list::-webkit-scrollbar { width: 4px; }
.modal-list::-webkit-scrollbar-thumb { background: #3b82f6; border-radius: 4px; }
.selectable-list .list-item { cursor: pointer; }
.selectable-list .list-item.selected { background: rgba(59, 130, 246, 0.2); border-left: 4px solid #3b82f6; }

/* АДАПТИВНОСТЬ */
@media (max-width: 768px) {
    .app-container { max-width: 100%; }
    .sidebar { width: 100%; position: absolute; z-index: 10; height: 100%; border-right: none; transition: 0.3s transform; }
    .chat-area { width: 100%; }
    .mobile-only { display: block; }
    .sidebar.hidden-mobile { transform: translateX(-100%); }
    .message { max-width: 90%; }
    .message-image { max-width: 200px; min-height: 120px; min-width: 150px; }
}

/* Уведомление о непрочитанных сообщениях */
.chat-unread-badge {
    background: #ef4444; 
    width: 12px; 
    height: 12px; 
    border-radius: 50%;
    display: inline-block; 
    margin-left: auto;
    box-shadow: 0 0 5px rgba(239, 68, 68, 0.5);
}
