/* ============================================
   PyrBook Styles - Modern Social Network
   Light / Dark Theme with CSS Variables
   ============================================ */

/* ----- CSS Variables (Light Theme Default) ----- */
:root {
    /* Colors */
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f0f2f5;
    --text-primary: #1c1e21;
    --text-secondary: #65676b;
    --text-muted: #8d949e;
    --border: #e4e6eb;
    --border-light: #eef2f6;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
    --accent: #1877f2;
    --accent-hover: #166fe5;
    --danger: #e41e3f;
    --danger-hover: #c91d3a;
    --success: #31a24c;
    --warning: #f7b928;
    --transition: all 0.2s ease;
}

/* ----- Dark Theme Override ----- */
.dark-theme {
    --bg-body: #18191a;
    --bg-card: #242526;
    --bg-sidebar: #242526;
    --bg-input: #3a3b3c;
    --bg-hover: #3a3b3c;
    --text-primary: #e4e6eb;
    --text-secondary: #b0b3b8;
    --text-muted: #8d949e;
    --border: #3e4042;
    --border-light: #3a3b3c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.7);
    --accent: #2d88ff;
    --accent-hover: #4c9aff;
}

/* ----- Reset & Base ----- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Montserrat', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    transition: background-color 0.3s, color 0.2s;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    text-decoration: underline;
    opacity: 0.8;
}

button, input, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ----- Scrollbar (modern) ----- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-primary);
}

/* ----- Main Layout ----- */
.m-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* ----- Left Menu (Sidebar) ----- */
.left-menu {
    width: 80px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 0;
    gap: 28px;
    flex-shrink: 0;
    transition: var(--transition);
    z-index: 10;
}

.left-menu > div {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.left-menu > div:hover {
    background-color: var(--bg-hover);
}

.left-menu img {
    width: 28px;
    height: 28px;
    filter: invert(0.4);
    transition: filter 0.2s;
}

.dark-theme .left-menu img {
    filter: invert(0.9);
}

/* Notification badge */
.notif-badge {
    position: relative;
}
.notif-badge[data-count]::after {
    content: attr(data-count);
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 20px;
    padding: 0 5px;
    box-shadow: 0 0 0 2px var(--bg-sidebar);
    display: none;
}
.notif-badge[data-count]:not([data-count="0"])::after {
    display: block;
}

/* ----- Right Main Content ----- */
.right-main {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    scroll-behavior: smooth;
}

/* ----- Cards & Common Components ----- */
.profile-card,
.post,
.friend-card,
.notification-card,
.user-search-card,
.messages-friend,
.message,
.user-card-posts,
.auth-card,
.settings-page,
.welcome {
    background-color: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    margin-bottom: 24px;
    padding: 20px;
    border: 1px solid var(--border);
}

/* Buttons */
button,
.friend-btn,
.edit-button span {
    background-color: var(--accent);
    border: none;
    color: white;
    padding: 10px 18px;
    border-radius: 40px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

button:hover,
.friend-btn:hover {
    background-color: var(--accent-hover);
    transform: scale(1.02);
}

button.danger {
    background-color: var(--danger);
}
button.danger:hover {
    background-color: var(--danger-hover);
}

input, textarea {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    transition: var(--transition);
    width: 100%;
    margin-top: 8px;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.2);
}

/* ----- Profile Page ----- */
.profile-back {
    width: 100%;
    height: 280px;
    background-size: cover;
    background-position: center;
    border-radius: 20px;
    position: relative;
    margin-bottom: -60px;
    z-index: 1;
}

.edit-button {
    position: absolute;
    top: 20px;
    left: 20px;
    background: var(--bg-card);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}
.edit-button:hover {
    transform: scale(1.1);
}
.edit-button span {
    font-size: 24px;
    background: transparent;
    padding: 0;
    color: var(--text-primary);
}

.profile-card {
    display: flex;
    align-items: center;
    gap: 24px;
    position: relative;
    z-index: 2;
    flex-wrap: wrap;
}
.profile-avatar {
    width: 120px;
    height: 120px;
    background-size: cover;
    background-position: center;
    border-radius: 50%;
    border: 4px solid var(--bg-card);
    box-shadow: var(--shadow-md);
}
.profile-info h1 {
    font-size: 2rem;
    margin-bottom: 8px;
}
.profile-details {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 20px;
    margin-top: 20px;
}
.profile-details ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
    list-style: none;
    margin-top: 16px;
}
.profile-details li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

/* Edit Window */
.edit-window {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    background: var(--bg-card);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow-y: auto;
    border: 1px solid var(--border);
}
.edit-window img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-top: 12px;
}

/* Posts */
.posts-section {
    margin-top: 32px;
}
.post-form {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 24px;
}
.post-form textarea {
    min-height: 100px;
    resize: vertical;
}
.image-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0;
}
.image-inputs input {
    flex: 1;
    min-width: 120px;
}
.post {
    margin-bottom: 20px;
    transition: var(--transition);
}
.post:hover {
    transform: translateY(-2px);
}
.post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.post-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}
.post-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 15px 0;
}
.post-images img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    object-fit: cover;
    cursor: pointer;
}
.post-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 12px;
}
.delete-post {
    margin-left: auto;
    color: var(--danger);
    font-weight: bold;
    cursor: pointer;
}

/* News Feed */
.news-feed h1 {
    margin-bottom: 24px;
}
#load-more {
    width: 100%;
    margin-top: 20px;
}

/* Friends List */
.friends-page h1 {
    margin-bottom: 24px;
}
.friends-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}
.friend-card {
    text-align: center;
    margin-bottom: 0;
}
.friend-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-size: cover;
    margin: 0 auto 12px;
}
.friend-name {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 12px;
}

/* Messages */
.messages-container {
    display: flex;
    height: calc(100vh - 80px);
    background: var(--bg-card);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.friends-sidebar {
    width: 280px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 16px;
}
.friends-sidebar h3 {
    margin-bottom: 16px;
    padding-left: 8px;
}
.message-friend {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 6px;
}
.message-friend:hover {
    background: var(--bg-hover);
}
.message-friend img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    background: var(--bg-card);
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.message {
    max-width: 70%;
    padding: 10px 16px;
    border-radius: 20px;
    background: var(--bg-hover);
    word-wrap: break-word;
    margin-bottom: 4px;
}
.message.me {
    align-self: flex-end;
    background: var(--accent);
    color: white;
}
.message.friend {
    align-self: flex-start;
}
.chat-input {
    display: flex;
    padding: 16px;
    border-top: 1px solid var(--border);
    gap: 12px;
    background: var(--bg-card);
}
.chat-input textarea {
    flex: 1;
    margin: 0;
    resize: none;
}
.chat-input button {
    align-self: flex-end;
}

/* Notifications */
.notifications-page h1 {
    margin-bottom: 24px;
}
.notification-card {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.notif-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
}
.notif-content {
    flex: 1;
}
.notif-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

/* Search */
.search-page h1 {
    margin-bottom: 16px;
}
#search-input {
    margin-bottom: 24px;
}
.user-search-card {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: space-between;
}
.search-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

/* Settings */
.settings-page {
    max-width: 600px;
    margin: 0 auto;
}
.switch-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.switch-label input {
    width: auto;
    margin: 0;
    transform: scale(1.3);
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-body) 0%, var(--bg-card) 100%);
}
.auth-card {
    width: 100%;
    max-width: 500px;
    transition: margin 0.4s ease;
    position: absolute;
    left: 0;
    right: 0;
    margin: 0 auto;
}
#login {
    margin-top: 5vh;
}
#reg {
    margin-top: 200vh;
}
.reg-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.toggle-link {
    text-align: right;
    margin: 16px 0 12px;
    cursor: pointer;
    color: var(--accent);
    font-weight: 500;
}
.error {
    color: var(--danger);
    background: rgba(228, 30, 63, 0.1);
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 16px;
}
.success {
    color: var(--success);
    background: rgba(49, 162, 76, 0.1);
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 16px;
}

/* Welcome Page */
.welcome {
    text-align: center;
    margin-top: 20vh;
}
.welcome h1 {
    font-size: 2.5rem;
    margin-bottom: 16px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .right-main {
        padding: 20px;
    }
    .profile-card {
        flex-direction: column;
        text-align: center;
    }
    .profile-details ul {
        grid-template-columns: 1fr;
    }
    .left-menu {
        width: 70px;
        gap: 20px;
    }
    .messages-container {
        flex-direction: column;
        height: auto;
    }
    .friends-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        display: flex;
        overflow-x: auto;
        gap: 12px;
    }
    .message-friend {
        flex-direction: column;
        min-width: 80px;
        text-align: center;
    }
    .chat-messages {
        height: 50vh;
    }
}

@media (max-width: 768px) {
    .m-container {
        flex-direction: column;
    }
    .left-menu {
        width: 100%;
        flex-direction: row;
        justify-content: space-around;
        padding: 12px;
        gap: 0;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .right-main {
        padding: 16px;
    }
    .reg-grid {
        grid-template-columns: 1fr;
    }
    .profile-back {
        height: 180px;
    }
    .profile-avatar {
        width: 90px;
        height: 90px;
    }
    button, .friend-btn {
        padding: 8px 14px;
        font-size: 0.8rem;
    }
    .edit-window {
        width: 95%;
        padding: 16px;
    }
}

.setting-group {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.setting-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}
.setting-group select,
.setting-group input[type="number"] {
    width: 100%;
    max-width: 300px;
}
.switch-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.switch-label input {
    width: auto;
    transform: scale(1.2);
    margin: 0;
}
.save-settings {
    margin-top: 20px;
    width: 100%;
}

/* ----- Новые стили для настроек и форм ----- */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.setting-group {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.setting-group label:first-child {
    font-weight: 600;
    display: block;
    margin-bottom: 12px;
    font-size: 1.1rem;
}
.switch-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.switch-label input {
    transform: scale(1.2);
    margin: 0;
}
/* Красивый toggle switch для тёмной темы */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 15px;
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 30px;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}
input:checked + .toggle-slider {
    background-color: var(--accent);
}
input:checked + .toggle-slider:before {
    transform: translateX(30px);
}

/* Custom select */
.custom-select {
    position: relative;
    width: 100%;
    max-width: 300px;
}
.custom-select select {
    appearance: none;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    width: 100%;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.9rem;
}
.custom-select::after {
    content: "▼";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-secondary);
}
.setting-group select:focus {
    border-color: var(--accent);
    outline: none;
}

/* Edit window header */
.edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.close-btn:hover {
    background: var(--bg-hover);
    color: var(--danger);
}

/* Image rows in post form */
.img-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.img-row input[type="url"] {
    flex: 2;
}
.img-row input[type="file"] {
    flex: 1;
}

/* Стилизованный select */
.styled-select select {
    appearance: none;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    width: 100%;
    max-width: 300px;
    color: var(--text-primary);
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23656b7c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
}
.styled-select select:focus {
    outline: none;
    border-color: var(--accent);
}
.save-settings {
    background: var(--accent);
    color: white;
    padding: 12px 20px;
    border-radius: 40px;
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}
.save-settings:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}
/* Окно редактирования профиля */
.edit-window {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    background: var(--bg-card);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow-y: auto;
    border: 1px solid var(--border);
}
.edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.edit-header h2 {
    margin: 0;
}
.btn-icon {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
}
.btn-icon:hover {
    color: var(--danger);
}
.edit-window img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin: 12px 0;
}
/* Toast уведомления */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    padding: 10px 20px;
    border-radius: 40px;
    box-shadow: var(--shadow-md);
    z-index: 2000;
    animation: fadeInOut 2s ease forwards;
}
@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* Lightbox (просмотр изображений) */
.lightbox {
    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;
}
.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
}
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: white;
    cursor: pointer;
}
/* Модальное окно редактирования поста */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}
.modal-content {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 16px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
}
.current-images {
    margin: 15px 0;
}
.images-checkbox-list {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}
.image-checkbox {
    text-align: center;
}
.post-actions {
    margin-left: auto;
    display: flex;
    gap: 10px;
}
.edit-post-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0 5px;
}
.edit-post-btn:hover {
    color: var(--accent);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.post, .friend-card, .notification-card {
    animation: fadeIn 0.3s ease forwards;
}

/* Utility */
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.flex { display: flex; gap: 12px; align-items: center; }

/* ========== Auth Page (Login/Register) ========== */
.auth-body {
    background: linear-gradient(135deg, var(--bg-body) 0%, var(--bg-card) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-card {
    width: 100%;
    max-width: 500px;
    transition: margin 0.4s ease, opacity 0.3s;
    position: absolute;
    left: 0;
    right: 0;
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
}
.auth-card h1 {
    font-size: 2rem;
    margin-bottom: 20px;
    text-align: center;
}
.auth-card input {
    width: 100%;
    margin-bottom: 15px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
}
.auth-card button {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 40px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}
.auth-card button:hover {
    background: var(--accent-hover);
}
.toggle-link {
    text-align: right;
    margin: 16px 0 12px;
    cursor: pointer;
    color: var(--accent);
    font-weight: 500;
}
.error {
    color: var(--danger);
    background: rgba(228, 30, 63, 0.1);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 16px;
    text-align: center;
}
.success {
    color: var(--success);
    background: rgba(49, 162, 76, 0.1);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 16px;
    text-align: center;
}
.reg-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .auth-card {
        max-width: 90%;
        padding: 20px;
        margin: 0 auto;
    }
    .reg-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    #login {
        margin-top: 20vh;
    }
    
    .auth-card h1 {
        font-size: 1.8rem;
    }
    .auth-card input, .auth-card button {
        font-size: 16px; /* предотвращает автоматическое масштабирование на iOS */
        padding: 12px;
    }
}
@media (max-width: 480px) {
    .auth-card {
        padding: 15px;
    }
    .toggle-link {
        font-size: 14px;
    }
}

/* Перенос текста в постах */
.post p {
    word-wrap: break-word;
    white-space: normal;
    overflow-wrap: break-word;
}

/* Кнопки сброса аватара/фона */
.reset-image-btn {
    background: var(--danger);
    margin-top: 5px;
    padding: 5px 10px;
    font-size: 12px;
}
.reset-image-btn:hover {
    background: var(--danger-hover);
}

/* Для увеличения аватара/фона в лайтбоксе */
.avatar-lightbox, .background-lightbox {
    cursor: pointer;
    transition: opacity 0.2s;
}
.avatar-lightbox:hover, .background-lightbox:hover {
    opacity: 0.9;
}

/* Удаление из друзей */
.remove-friend {
    background: var(--danger);
    margin-left: 10px;
}
.remove-friend:hover {
    background: var(--danger-hover);
}

/* Кнопки действий в посте */
.post-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}
.edit-post-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0 5px;
}
.edit-post-btn:hover {
    color: var(--accent);
}

.online-indicator, .offline-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-left: 8px;
    font-size: 0;
}
.online-indicator {
    background: #31a24c;
    box-shadow: 0 0 0 2px var(--bg-card);
}
.offline-indicator {
    background: #8d949e;
    box-shadow: 0 0 0 2px var(--bg-card);
}


.unread-badge {
    background: #e41e3f;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: bold;
    margin-left: auto;
}
.msg-status {
    font-size: 12px;
    margin-left: 4px;
    opacity: 0.8;
}
.msg-read {
    color: #1877f2;
}
.dark-theme .msg-read {
    color: #4c9aff;
}

/* Чат – стили для десктопа и мобильных */
.messages-container {
    display: flex;
    height: calc(100vh - 80px);
    background: var(--bg-card);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    position: relative;
}
.friends-sidebar {
    width: 280px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 16px;
}
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}
.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    background: var(--bg-card);
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* На мобильных будет отступ снизу, чтобы не перекрывалось полем ввода */
}
.chat-input {
    display: flex;
    padding: 16px;
    border-top: 1px solid var(--border);
    gap: 12px;
    background: var(--bg-card);
    transition: all 0.2s;
}
.chat-input textarea {
    flex: 1;
    margin: 0;
    resize: none;
    border-radius: 24px;
    padding: 12px 16px;
}
.chat-input button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: var(--transition);
}
.chat-input button:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.message {
    max-width: 70%;
    padding: 10px 12px;
    border-radius: 18px;
    background: var(--bg-hover);
    word-wrap: break-word;
}
.message.me {
    align-self: flex-end;
    background: var(--accent);
    color: white;
}
.message.friend {
    align-self: flex-start;
}
.msg-text {
    font-size: 14px;
    line-height: 1.4;
}
.msg-time {
    font-size: 10px;
    color: inherit;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}
.message.me .msg-time {
    text-align: right;
}
.message.friend .msg-time {
    text-align: left;
}
.msg-status {
    font-size: 12px;
    margin-left: 4px;
    opacity: 0.8;
}
.msg-read {
    color: #b0d4ff;
}
.dark-theme .msg-read {
    color: #7abaff;
}

/* Кнопки действий над сообщением */
.msg-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}
.message:hover .msg-actions {
    opacity: 1;
}
.msg-edit, .msg-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 12px;
    color: var(--text-secondary);
}
.msg-edit:hover {
    background: var(--bg-hover);
    color: var(--accent);
}
.msg-delete:hover {
    background: var(--bg-hover);
    color: var(--danger);
}
.msg-edited {
    font-size: 10px;
    opacity: 0.7;
    margin-left: 4px;
}
.deleted-message {
    opacity: 0.6;
    background: var(--bg-hover);
}
.deleted-message .msg-text {
    font-style: italic;
}

/* Мобильная адаптация чата */
@media (max-width: 768px) {
    .messages-container {
        flex-direction: column;
        height: calc(100vh - 60px);
        border-radius: 0;
    }
    .friends-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        display: flex;
        overflow-x: auto;
        gap: 12px;
        padding: 12px;
        order: 1;
    }
    .message-friend {
        flex-direction: column;
        min-width: 80px;
        text-align: center;
        background: var(--bg-card);
        border-radius: 16px;
        padding: 8px;
    }
    .chat-area {
        order: 2;
        height: calc(100% - 100px);
        display: flex;
        flex-direction: column;
    }
    .chat-messages {
        flex: 1;
        padding-bottom: 80px; /* отступ под фиксированное поле ввода */
    }
    .chat-input {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        border-radius: 20px 20px 0 0;
        padding: 12px;
        z-index: 100;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
    .chat-input textarea {
        font-size: 16px; /* предотвращает масштабирование на iOS */
        padding: 10px 14px;
    }
    .chat-input button {
        width: 44px;
        height: 44px;
        font-size: 22px;
    }
}