
/* Общие стили */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    color: #1c1e21;
    overflow: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.hidden {
    display: none !important;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background-color 0.3s, transform 0.2s;
}

.btn-primary {
    background-color: #1877f2;
    color: #fff;
}
.btn-primary:hover {
    background-color: #166fe5;
}

.btn-danger {
    background-color: #fa383e;
    color: white;
}

/* --- Шапка --- */
header {
    background-color: #fff;
    padding: 10px 0;
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 0;
    z-index: 999;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header .header__logo {
    font-size: 1.2rem;
    color: #1877f2;
    text-decoration: none;
    font-weight: bold;
}

header nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

header nav a {
    text-decoration: none;
    color: #606770;
    font-weight: 500;
}
header nav a.active {
    color: #1877f2;
}

#header-user-menu {
    position: relative;
    cursor: pointer;
}

#user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px;
    border-radius: 18px;
    transition: background-color 0.2s;
}
#user-menu-toggle:hover {
    background-color: #f0f2f5;
}

#header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

#header-nickname {
    font-weight: 600;
}

#user-menu-dropdown {
    position: absolute;
    top: 110%;
    right: 0;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    width: 200px;
    overflow: hidden;
    padding: 8px 0;
}

#user-menu-dropdown a {
    display: block;
    padding: 10px 15px;
    color: #1c1e21;
    text-decoration: none;
}
#user-menu-dropdown a:hover {
    background-color: #f0f2f5;
}

/* Стили для страницы аутентификации */
.auth-page-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}
#auth-container {
    background-color: #fff;
    padding: 2rem 2.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 380px;
}
#auth-container h2 {
    text-align: center;
    color: #1c1e21;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}
#auth-container form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
#auth-container input {
    padding: 0.9rem;
    border: 1px solid #dddfe2;
    border-radius: 6px;
    font-size: 1rem;
}
#auth-container button {
    padding: 0.9rem;
    border: none;
    border-radius: 6px;
    background-color: #1877f2;
    color: #fff;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}
#auth-container button:hover {
    background-color: #166fe5;
}
.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    padding-top: 1rem;
    border-top: 1px solid #e4e6eb;
}
.auth-switch a {
    color: #1877f2;
    text-decoration: none;
    font-weight: 600;
}
.error-message {
    color: #fa383e;
    background-color: #ffebee;
    border: 1px solid #fa383e;
    padding: 0.8rem;
    border-radius: 6px;
    text-align: center;
    margin-top: 1rem;
}

/* Стили для страницы чата */
#main-container {
    display: flex;
    height: calc(100vh - 61px); /* Высота экрана минус высота шапки */
    background-color: #fff;
    max-width: 1440px;
    margin: 0 auto;
}

#sidebar {
    width: 30%;
    min-width: 300px;
    max-width: 400px;
    /* border-right: 1px solid #e0e0e0; */
    display: flex;
    flex-direction: column;
    /* background-color: #f8f9fa; */

    position: absolute;
    height: 80%;
    z-index: 100;
    top: 10%;
    left: 40px;

    border-radius: 20px;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px); /* Для поддержки Safari */
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

#user-search-container {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
}
#user-search-form {
    display: flex;
    position: relative;
}
#user-search-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 20px;
}
#user-search-results {
    margin-top: 10px;
}
.user-search-item {
    padding: 10px;
    cursor: pointer;
    border-radius: 8px;
}
.user-search-item:hover {
    background-color: #e4e6eb;
}

#chat-list {
    flex-grow: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 15px;
    gap: 15px;
    cursor: pointer;
}
.chat-item:hover {
    background-color: #e9ecef;
}
.chat-item.active {
    background-color: #dceafc;
}
.chat-item .avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
}
.chat-item-details {
    flex-grow: 1;
    overflow: hidden;
}
.chat-item-user {
    font-weight: 500;
}
.chat-item-last-message {
    color: #606770;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    font-size: 0.8rem;
}
.chat-item-time {
    color: #8a8d91;
}
.unread-badge {
    background-color: #0084ff;
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: bold;
}

#main-chat {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-size: cover;
    background-position: center;
}

#placeholder-view {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: #606770;
    font-size: 1.2rem;
}

#chat-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

#chat-header {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f8f9fa;
    cursor: pointer;
}
#chat-header-info {
    flex-grow: 1;
    margin-left: 15px;
}
#chat-header-username {
    font-weight: 600;
}
#chat-header-last-seen {
    font-size: 0.8rem;
    color: #606770;
}
#chat-header-last-seen.online {
    color: #31a24c;
    font-weight: 600;
}

#messages-container {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 80px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}
.message.sent {
    align-self: flex-end;
    align-items: flex-end;
}
.message.received {
    align-self: flex-start;
    align-items: flex-start;
}
.message-content {
    padding: 10px 15px;
    border-radius: 18px;
}
.message.sent .message-content {
    background-color: #0084ff;
    color: white;
}
.message.received .message-content {
    background-color: #e4e6eb;
}
.sticker-message .message-content {
    background-color: transparent;
    padding: 0;
}
.sticker-content {
    max-width: 150px;
}
.message-meta {
    font-size: 0.75rem;
    color: #606770;
    margin-top: 5px;
    padding: 0 5px;
}
.read-status-icon {
    font-weight: bold;
    color: #4fc3f7;
}

#message-form {
    position: absolute;
    bottom: 0;
    width: 100%;
    display: flex;
    align-items: center;
    margin: 20px;
    padding: 10px 20px;
    gap: 10px;
    /* border-top: 1px solid #e0e0e0; */
    /* background-color: #fff; */

    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
#message-input {
    flex-grow: 1;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 20px;
}
#send-message-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 20px;
    background-color: #0084ff;
    color: white;
    cursor: pointer;
}

/* --- Модальные о��на --- */
.modal, .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-content {
    background: white;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.close-button, .close-modal-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.8rem;
    cursor: pointer;
    color: #aaa;
    line-height: 1;
}
.selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 1rem;
    max-height: 300px;
    overflow-y: auto;
}
.avatar-option, .background-option, .sticker-option {
    width: 100%;
    padding-top: 100%;
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    border: 3px solid transparent;
    background-size: cover;
    background-position: center;
}
.avatar-option.selected, .background-option.selected {
    border-color: #0084ff;
}
.avatar-option img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
}
.sticker-option {
    padding: 0;
}
.sticker-option img {
    max-width: 100%;
}

/* --- Страница профиля --- */
.profile-page-container {
    padding-top: 30px;
}
.profile-main {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
    align-items: start;
}
.profile-card {
    background-color: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
}
.profile-avatar-large-wrapper {
    width: 150px;
    height: 150px;
    margin: 0 auto 20px;
    border-radius: 50%;
    overflow: hidden;
}
#profile-avatar-large {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
#profile-nickname-large {
    font-size: 1.5rem;
    margin-bottom: 5px;
}
#profile-login-info, #profile-register-date {
    color: #606770;
    font-size: 0.9rem;
}
#profile-page-buttons {
    margin-top: 20px;
}

.profile-posts-card {
    background-color: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.post-form-container {
    margin-bottom: 20px;
}
#create-post-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    min-height: 80px;
    margin-bottom: 10px;
}
#create-post-form {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

#posts-container .post-item {
    padding: 15px;
    border-top: 1px solid #e4e6eb;
}
#posts-container .post-item:first-child {
    border-top: none;
}
.post-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.post-header .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}
.post-author-info .nickname {
    font-weight: 600;
}
.post-author-info .post-date {
    font-size: 0.8rem;
    color: #606770;
}
.post-content {
    margin-bottom: 10px;
}
.post-actions {
    text-align: right;
}
.delete-post-btn {
    background: none;
    border: none;
    color: #606770;
    cursor: pointer;
    font-size: 0.8rem;
}
.delete-post-btn:hover {
    text-decoration: underline;
}

/* --- Страница пользователей --- */
.user-list-page-container {
    padding-top: 30px;
}
.user-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}
.user-list-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}
.user-list-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.user-list-item .avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}
.user-list-item .user-info {
    display: flex;
    flex-direction: column;
}
.user-list-item .nickname {
    font-weight: 600;
}
.user-list-item .login {
    font-size: 0.9rem;
    color: #606770;
}
