/* style.css — современный мессенджер с единым стилем сообщений */

:root {
    --bg-gradient-start: #0b0f19;
    --bg-gradient-end: #1a1025;
    --glass-bg: rgba(20, 15, 35, 0.75);
    --glass-border: rgba(255, 255, 255, 0.06);
    --primary: #7c3aed;
    --primary-light: #a78bfa;
    --primary-dark: #5b21b6;
    --accent: #3b82f6;
    --accent-light: #60a5fa;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text-primary: #ffffff;
    --text-secondary: #e2e8f0;
    --text-muted: #94a3b8;
    --surface-dark: rgba(30, 20, 50, 0.8);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
    --radius-xl: 32px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 14px;
    --transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: fixed;
}

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at 30% 20%, #4c1d95, #0f172a);
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    color: var(--text-primary);
}

.glass-panel {
    width: 100%;
    height: 100dvh;
    background: var(--glass-bg);
    backdrop-filter: blur(35px);
    -webkit-backdrop-filter: blur(35px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid var(--glass-border);
}

@media (min-width: 721px) {
    body {
        padding: 12px;
        position: static;
    }
    .glass-panel {
        max-width: 1400px;
        height: 94vh;
        max-height: 950px;
        border-radius: var(--radius-xl);
        box-shadow: var(--shadow-lg);
        position: relative;
    }
}

#authScreen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 24px;
    overflow-y: auto;
}

.auth-card {
    background: rgba(30, 20, 50, 0.7);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 48px;
    padding: 44px 36px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(124, 58, 237, 0.25);
    margin: auto;
}

.auth-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 32px;
}

.auth-header i {
    font-size: 52px;
    background: linear-gradient(145deg, var(--primary-light), var(--accent-light));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.auth-header h2 {
    font-weight: 700;
    font-size: 34px;
    letter-spacing: -0.5px;
    color: white;
}

.input-wrapper {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 28px;
    padding: 4px 22px;
    margin-bottom: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    background: rgba(124, 58, 237, 0.1);
}

.input-wrapper i {
    color: var(--primary-light);
    width: 32px;
    font-size: 18px;
}

.input-wrapper input, .input-wrapper select, .input-wrapper textarea {
    width: 100%;
    padding: 18px 0;
    background: transparent;
    border: none;
    outline: none;
    font-size: 16px;
    font-weight: 500;
    color: white;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.phone-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.phone-prefix {
    font-weight: 600;
    font-size: 16px;
    color: var(--primary-light);
    background: rgba(124, 58, 237, 0.2);
    padding: 6px 14px;
    border-radius: 40px;
}

.phone-wrapper input {
    flex: 1;
    min-width: 0;
}

.password-wrapper {
    position: relative;
}

#togglePassword {
    position: absolute;
    right: 22px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-light);
    font-size: 20px;
    cursor: pointer;
}

.auth-actions {
    display: flex;
    gap: 14px;
    margin-top: 32px;
}

.btn {
    flex: 1;
    padding: 18px 12px;
    border-radius: 60px;
    border: none;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.btn-primary {
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 12px 20px -6px rgba(124, 58, 237, 0.4);
}

.btn-primary:hover {
    transform: scale(0.98);
    box-shadow: 0 6px 12px -4px var(--primary);
}

.btn-outline {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
}

#messengerScreen {
    display: none;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.app-layout {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

.contacts-sidebar {
    width: 350px;
    background: rgba(15, 10, 25, 0.5);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    transition: transform 0.3s ease;
    z-index: 20;
    height: 100%;
    overflow-y: auto;
}

.profile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px 18px;
    flex-shrink: 0;
}

.profile-badge {
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
}

.avatar-lg {
    width: 56px;
    height: 56px;
    background: linear-gradient(145deg, var(--primary), #3b0764);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 22px;
    box-shadow: var(--shadow-sm);
}

.user-info h4 {
    font-weight: 700;
    color: white;
    font-size: 17px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-info span {
    font-size: 12px;
    color: var(--text-muted);
}

.admin-badge {
    background: linear-gradient(145deg, #fbbf24, #d97706);
    color: black;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 700;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 48px;
    height: 48px;
    border-radius: 18px;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(124, 58, 237, 0.25);
    border-color: var(--primary);
    color: white;
}

.search-box {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 28px;
    padding: 10px 20px;
    margin: 8px 0 18px;
    display: flex;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.search-box i {
    color: var(--primary-light);
    margin-right: 14px;
    font-size: 18px;
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    font-size: 16px;
    color: white;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-results {
    background: rgba(30, 20, 50, 0.9);
    backdrop-filter: blur(25px);
    border-radius: 24px;
    margin-top: 4px;
    margin-bottom: 16px;
    max-height: 350px;
    overflow-y: auto;
    display: none;
    border: 1px solid var(--glass-border);
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(124, 58, 237, 0.15);
}

.search-result-avatar {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: linear-gradient(145deg, var(--primary), #4c1d95);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 18px;
}

.search-result-info {
    flex: 1;
}

.search-result-name {
    font-weight: 600;
    color: white;
    font-size: 15px;
}

.search-result-phone {
    font-size: 12px;
    color: var(--text-muted);
}

.search-result-add {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.search-result-add:hover {
    background: var(--primary-dark);
    transform: scale(0.95);
}

.section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--primary-light);
    margin: 12px 0 10px 10px;
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.contact-card {
    padding: 14px 16px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.contact-card:hover {
    background: rgba(124, 58, 237, 0.15);
    border-color: rgba(124, 58, 237, 0.3);
}

.contact-card.active {
    background: rgba(124, 58, 237, 0.25);
    border-color: var(--primary);
}

.contact-avatar {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    background: linear-gradient(145deg, #5b21b6, #2e1065);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    position: relative;
    flex-shrink: 0;
    font-size: 20px;
}

.online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    background: var(--success);
    border: 3px solid #1a1025;
    border-radius: 50%;
}

.contact-preview {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-weight: 650;
    color: white;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.last-message {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.last-message i {
    font-size: 12px;
    opacity: 0.8;
}

.contact-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.last-message-time {
    font-size: 11px;
    color: var(--text-muted);
}

.unread-badge {
    background: var(--primary);
    color: white;
    border-radius: 30px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
    min-width: 24px;
    text-align: center;
}

.create-channel-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 12px 8px;
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    backdrop-filter: blur(5px);
}

.create-channel-btn:hover {
    background: rgba(124, 58, 237, 0.25);
    border-color: var(--primary);
}

.create-channel-btn i {
    font-size: 16px;
    color: var(--primary-light);
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(20, 15, 35, 0.3);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

.chat-topbar {
    padding: 16px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
    gap: 10px;
}

.chat-contact-info {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    cursor: pointer;
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    background: linear-gradient(145deg, var(--primary), #4c1d95);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    flex-shrink: 0;
    color: white;
}

.chat-name-status {
    min-width: 0;
}

.chat-name-status h3 {
    font-weight: 700;
    color: white;
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-badge {
    font-size: 12px;
    color: var(--text-muted);
    display: inline-block;
}

.touch-id-btn {
    background: rgba(124, 58, 237, 0.2);
    border: 1px solid rgba(124, 58, 237, 0.4);
    backdrop-filter: blur(10px);
    padding: 10px 18px;
    border-radius: 60px;
    font-weight: 600;
    font-size: 14px;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.touch-id-btn i {
    font-size: 24px;
    color: var(--primary-light);
}

.touch-id-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* Закреплённые сообщения (бар) */
.pinned-messages-bar {
    background: rgba(124, 58, 237, 0.1);
    border-bottom: 1px solid var(--primary);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.pinned-messages-bar::-webkit-scrollbar {
    height: 3px;
}

.pinned-messages-bar::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.pinned-message-preview {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 30px;
    padding: 6px 14px;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(124, 58, 237, 0.2);
    transition: var(--transition);
}

.pinned-message-preview:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: var(--primary);
}

.pinned-message-preview i {
    color: var(--primary-light);
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

.message-row {
    display: flex;
    max-width: 70%;
    margin-bottom: 4px;
}
.message-row.own {
    align-self: flex-end;
}
.message-row.other {
    align-self: flex-start;
}
@media (max-width: 720px) {
    .message-row {
        max-width: 88%;
    }
}
@media (max-width: 480px) {
    .message-row {
        max-width: 92%;
    }
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    font-size: 15px;
    line-height: 1.45;
    word-break: break-word;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    color: white;
    position: relative;
    width: fit-content;
    max-width: 100%;
    transition: all 0.15s ease;
}
.own .message-bubble {
    background: linear-gradient(145deg, var(--primary), #6d28d9);
    border-bottom-right-radius: 6px;
}
.other .message-bubble {
    border-bottom-left-radius: 6px;
}

.message-transfer {
    background: linear-gradient(145deg, #b45309, #92400e) !important;
    border: 1px solid #fbbf24 !important;
}
.message-transfer .message-text {
    display: flex;
    align-items: center;
    gap: 8px;
}
.message-transfer .message-text i {
    color: #fbbf24;
    font-size: 18px;
}

.media-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.message-bubble img,
.message-bubble video:not(.video-note-video) {
    max-width: 260px;
    max-height: 260px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    object-fit: cover;
    cursor: pointer;
}
@media (max-width: 720px) {
    .message-bubble img,
    .message-bubble video:not(.video-note-video) {
        max-width: 220px;
        max-height: 220px;
    }
}
@media (max-width: 480px) {
    .message-bubble img,
    .message-bubble video:not(.video-note-video) {
        max-width: 180px;
        max-height: 180px;
    }
}

.video-note-container {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    overflow: hidden;
    background: #000;
    border: 2px solid var(--primary);
    position: relative;
}
.video-note-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
@media (max-width: 480px) {
    .video-note-container {
        width: 110px;
        height: 110px;
    }
}

.custom-audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 40px;
    padding: 6px 14px 6px 6px;
    min-width: 200px;
}
@media (max-width: 480px) {
    .custom-audio-player {
        min-width: 160px;
        gap: 8px;
    }
}
.custom-audio-player .play-pause-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    flex-shrink: 0;
}
.custom-audio-player .play-pause-btn:hover {
    background: var(--primary-dark);
    transform: scale(0.95);
}
.custom-audio-player .progress-container {
    flex: 1;
    cursor: pointer;
}
.custom-audio-player .progress-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}
.custom-audio-player .progress-fill {
    height: 100%;
    width: 0%;
    background: white;
    border-radius: 2px;
    transition: width 0.1s linear;
}
.custom-audio-player .time-display {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 4px;
    font-weight: 500;
}

.file-attachment {
    margin: 4px 0;
}
.file-attachment .file-link {
    background: rgba(124, 58, 237, 0.2);
    padding: 10px 16px;
    border-radius: 24px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: white;
    text-decoration: none;
    transition: var(--transition);
    border: 1px solid rgba(124, 58, 237, 0.3);
}
.file-attachment .file-link:hover {
    background: rgba(124, 58, 237, 0.4);
}
.file-attachment .file-link i {
    font-size: 18px;
    color: var(--primary-light);
}
.file-attachment .file-name {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    word-break: break-all;
}

.message-quote {
    background: rgba(0, 0, 0, 0.3);
    border-left: 3px solid var(--primary-light);
    border-radius: 12px;
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}
.message-quote:hover {
    background: rgba(124, 58, 237, 0.2);
    border-left-color: var(--primary);
}
.message-quote .quote-author {
    font-weight: 600;
    color: var(--primary-light);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.message-quote .quote-text {
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}
.message-quote .quote-text i {
    opacity: 0.7;
}

.forwarded-badge {
    background: rgba(59, 130, 246, 0.2);
    border-left: 3px solid var(--accent);
    border-radius: 12px;
    padding: 6px 12px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--accent-light);
    display: flex;
    align-items: center;
    gap: 8px;
}
.forwarded-badge i {
    opacity: 0.8;
}

.channel-sender-name {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.msg-time {
    font-size: 11px;
    margin-top: 6px;
    opacity: 0.75;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}
.msg-time i {
    font-size: 12px;
}
.edited-badge {
    background: rgba(0, 0, 0, 0.25);
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    cursor: help;
}
.edited-badge i {
    margin-right: 3px;
}

/* Таймер исчезновения */
.auto-delete-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(239, 68, 68, 0.15);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    color: #f87171;
    margin-left: 8px;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.scheduled-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(59, 130, 246, 0.15);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    color: #60a5fa;
    margin-left: 8px;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Реакции */
.reactions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.reaction-badge {
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 20px;
    padding: 4px 8px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: var(--transition);
}
.reaction-badge:hover {
    background: rgba(124, 58, 237, 0.3);
}
.reaction-badge.active {
    background: var(--primary);
    border-color: var(--primary-light);
}

/* Опросы */
.poll-message {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 18px;
    padding: 16px;
    margin: 8px 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.poll-question {
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.poll-question i {
    color: var(--primary-light);
}
.poll-option {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 10px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
}
.poll-option:hover {
    background: rgba(124, 58, 237, 0.2);
}
.poll-option.selected {
    background: var(--primary);
    border-color: var(--primary-light);
}
.poll-bar {
    height: 6px;
    background: var(--primary);
    border-radius: 3px;
    margin-top: 6px;
    transition: width 0.3s ease;
}
.poll-votes {
    font-size: 12px;
    color: var(--text-muted);
}
.poll-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Упоминания */
.mention-suggestions {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--surface-dark);
    border-radius: 18px;
    border: 1px solid var(--primary);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    margin-bottom: 8px;
    width: 250px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.mention-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
}
.mention-item:hover {
    background: rgba(124, 58, 237, 0.2);
}
.mention-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}
.mention-name {
    font-weight: 600;
}
.mention-username {
    font-size: 12px;
    color: var(--text-muted);
}

.highlight-message {
    animation: highlightPulse 2s ease-out;
}
@keyframes highlightPulse {
    0% { background: rgba(124, 58, 237, 0.5); }
    100% { background: transparent; }
}

.encrypted-animation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 0;
    flex-wrap: wrap;
}
.encrypted-animation .bubble {
    width: 8px;
    height: 8px;
    background: var(--primary-light);
    border-radius: 50%;
    opacity: 0.7;
    animation: floatBubble 2.5s infinite ease-in-out;
}
.encrypted-animation .bubble:nth-child(odd) {
    animation-delay: 0.15s;
}
.encrypted-animation .bubble:nth-child(3n) {
    animation-delay: 0.3s;
}
@keyframes floatBubble {
    0%, 100% { transform: translateY(0) scale(0.8); opacity: 0.4; }
    50% { transform: translateY(-12px) scale(1.1); opacity: 1; }
}

.message-input-area {
    padding: 12px 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    border-top: 1px solid var(--glass-border);
    flex-shrink: 0;
    background: rgba(15, 10, 25, 0.3);
    backdrop-filter: blur(15px);
}
.attach-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 48px;
    height: 48px;
    border-radius: 18px;
    font-size: 22px;
    color: var(--primary-light);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.attach-btn:hover {
    background: var(--primary);
    color: white;
}
.msg-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 12px 18px;
    font-size: 15px;
    outline: none;
    backdrop-filter: blur(5px);
    min-width: 0;
    color: white;
    font-family: 'Inter', sans-serif;
    line-height: 1.4;
    max-height: 100px;
    overflow-y: auto;
    scrollbar-width: thin;
}
.msg-input:focus {
    border-color: var(--primary);
    background: rgba(124, 58, 237, 0.1);
}
.msg-input::placeholder {
    color: var(--text-muted);
}
.send-msg-btn {
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    border: none;
    width: 52px;
    height: 52px;
    border-radius: 28px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 10px 20px -4px rgba(124, 58, 237, 0.5);
    transition: var(--transition);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.send-msg-btn:hover {
    transform: scale(0.95);
}

.media-toggle-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 48px;
    height: 48px;
    border-radius: 28px;
    font-size: 20px;
    color: var(--primary-light);
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.media-toggle-btn:hover {
    background: var(--primary);
    color: white;
}
.media-toggle-btn.recording {
    background: #ef4444;
    color: white;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.3);
    animation: pulse-rec 1.5s infinite;
}
@keyframes pulse-rec {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.input-actions-group {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

/* Скрываем десктопные кнопки на мобильных */
@media (max-width: 720px) {
    .input-actions-group .icon-btn:not(#mediaModeToggle) {
        display: none;
    }
    
    .input-actions-group {
        gap: 0;
    }
}

.recording-overlay {
    position: fixed;
    z-index: 3000;
    background: rgba(20, 15, 35, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 60px;
    padding: 20px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    border: 2px solid var(--primary);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    transition: border-color 0.2s, transform 0.1s;
}
.recording-overlay.cancelling {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.2);
}
.recording-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
}
.recording-wave .wave-bar {
    width: 4px;
    height: 20px;
    background: var(--primary-light);
    border-radius: 4px;
    animation: waveAnimation 0.8s ease-in-out infinite;
}
.recording-wave .wave-bar:nth-child(2) { animation-delay: 0.1s; height: 28px; }
.recording-wave .wave-bar:nth-child(3) { animation-delay: 0.2s; height: 36px; }
.recording-wave .wave-bar:nth-child(4) { animation-delay: 0.3s; height: 28px; }
.recording-wave .wave-bar:nth-child(5) { animation-delay: 0.4s; height: 20px; }
@keyframes waveAnimation {
    0%, 100% { transform: scaleY(0.5); opacity: 0.6; }
    50% { transform: scaleY(1.2); opacity: 1; }
}
.recording-overlay.cancelling .wave-bar {
    background: var(--danger);
}
.recording-hint {
    font-size: 14px;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}
.recording-hint i {
    color: var(--primary-light);
    font-size: 18px;
}
.recording-overlay.cancelling .recording-hint i {
    color: var(--danger);
}

.reply-preview {
    background: rgba(124, 58, 237, 0.15);
    border-left: 4px solid var(--primary);
    border-radius: 16px;
    padding: 10px 14px;
    margin: 0 18px 8px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    backdrop-filter: blur(5px);
    color: white;
}
.reply-preview-content {
    flex: 1;
    min-width: 0;
}
.reply-preview-author {
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: 2px;
}
.reply-preview-text {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reply-preview-cancel {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
}
.reply-preview-cancel:hover {
    color: var(--danger);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 10, 25, 0.8);
    backdrop-filter: blur(15px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 18px;
}
.modal-card {
    background: var(--surface-dark);
    backdrop-filter: blur(35px);
    border-radius: 40px;
    padding: 30px 26px;
    width: 100%;
    max-width: 480px;
    max-height: 90dvh;
    overflow-y: auto;
    box-shadow: 0 40px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(124, 58, 237, 0.2);
    color: white;
}
.modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.modal-header i {
    font-size: 34px;
    background: linear-gradient(145deg, var(--primary-light), var(--accent-light));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.modal-title {
    font-size: 26px;
    font-weight: 700;
}
.modal-actions {
    display: flex;
    gap: 14px;
    margin-top: 24px;
}

.pin-input-area {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 28px;
    padding: 8px 22px;
    margin: 20px 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    transition: var(--transition);
}

.pin-input-area:focus-within {
    border-color: var(--primary);
    background: rgba(124, 58, 237, 0.1);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.pin-input-area input {
    width: 100%;
    padding: 18px 0;
    font-size: 20px;
    text-align: center;
    letter-spacing: 12px;
    font-weight: 600;
    border: none;
    outline: none;
    background: transparent;
    color: white;
    font-family: 'Inter', monospace;
}

.pin-input-area input::placeholder {
    color: var(--text-muted);
    font-size: 16px;
    letter-spacing: normal;
    font-weight: 400;
}

@keyframes pinPulse {
    0%, 100% { border-color: rgba(255, 255, 255, 0.1); }
    50% { border-color: var(--primary-light); }
}

.pin-input-area.highlight {
    animation: pinPulse 1.5s infinite;
}

#decryptPinModal .modal-actions .btn {
    flex: 1;
    padding: 16px 20px;
    font-size: 16px;
}

#decryptPromptMsg {
    margin-bottom: 20px;
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
    text-align: center;
}

.context-menu {
    position: fixed;
    background: rgba(30, 20, 50, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 8px;
    min-width: 200px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(124, 58, 237, 0.3);
    z-index: 1500;
    display: none;
    flex-direction: column;
    border: 1px solid rgba(124, 58, 237, 0.4);
    transform-origin: top left;
    animation: menuAppear 0.15s ease;
}
.context-menu.visible {
    display: flex;
}
@keyframes menuAppear {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.context-menu-item {
    background: transparent;
    border: none;
    color: white;
    padding: 12px 18px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    width: 100%;
}
.context-menu-item i {
    width: 20px;
    color: var(--primary-light);
}
.context-menu-item:hover {
    background: rgba(124, 58, 237, 0.25);
}

.profile-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    flex-wrap: wrap;
}
.tab-btn {
    background: transparent;
    border: none;
    padding: 10px 18px;
    border-radius: 40px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    color: var(--text-secondary);
}
.tab-btn.active {
    background: var(--primary);
    color: white;
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}
.balance-large {
    font-size: 36px;
    font-weight: 700;
    background: linear-gradient(145deg, var(--primary-light), white);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 16px 0;
}
.flex-buttons {
    display: flex;
    gap: 14px;
    margin: 20px 0;
}
.bank-details-card {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 24px;
    padding: 16px;
    font-family: 'Courier New', monospace;
    word-break: break-all;
    margin: 12px 0;
    border: 1px dashed var(--primary);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 2px;
    color: white;
}
.qr-container {
    text-align: center;
    margin: 20px 0;
}
.qr-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-top: 20px;
}
.info-text {
    background: rgba(124, 58, 237, 0.1);
    padding: 14px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 14px;
}
.instruction-step {
    margin-bottom: 14px;
    padding-left: 28px;
    position: relative;
}
.instruction-step i {
    position: absolute;
    left: 0;
    top: 3px;
    color: var(--primary-light);
}

.member-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.member-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.member-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}
.member-details h4 {
    margin: 0 0 4px;
    font-size: 14px;
    color: white;
}
.member-details p {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
}
.member-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.btn-outline-small {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
}
.btn-outline-small:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 15, 35, 0.95);
    backdrop-filter: blur(20px);
    color: white;
    padding: 14px 28px;
    border-radius: 60px;
    font-size: 15px;
    z-index: 2000;
    display: none;
    white-space: nowrap;
    font-weight: 500;
    border: 1px solid var(--primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.empty-state {
    text-align: center;
    color: var(--text-muted);
    margin-top: 60px;
    font-size: 16px;
}
.pin-warning {
    background: rgba(239, 68, 68, 0.1);
    border-radius: 20px;
    padding: 10px 18px;
    margin: 0 18px 14px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(5px);
    flex-shrink: 0;
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.menu-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 26px;
    margin-right: 10px;
    color: white;
    cursor: pointer;
    width: 46px;
    height: 46px;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    flex-shrink: 0;
}
.menu-toggle:hover {
    background: rgba(124, 58, 237, 0.2);
}
hr {
    margin: 20px 0;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.search-results .empty-state {
    margin-top: 20px;
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

/* ========== СТИЛИ ДЛЯ ИСТОРИИ ОПЕРАЦИЙ ========== */

.history-item {
    display: flex;
    align-items: flex-start;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    gap: 14px;
}

.history-icon {
    width: 42px;
    height: 42px;
    background: rgba(124, 58, 237, 0.15);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-light);
    font-size: 18px;
    flex-shrink: 0;
    border: 1px solid rgba(124, 58, 237, 0.2);
}

.history-details {
    flex: 1;
    min-width: 0;
}

.history-title {
    font-weight: 600;
    color: white;
    font-size: 14px;
    margin-bottom: 2px;
}

.history-counterpart {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.history-meta {
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.8;
}

.history-amount {
    font-weight: 700;
    font-size: 15px;
    text-align: right;
    min-width: 100px;
    flex-shrink: 0;
}

.history-amount.text-success {
    color: #34d399;
}

.history-amount.text-danger {
    color: #f87171;
}

.commission-info {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
}

.history-status {
    min-width: 90px;
    text-align: right;
    flex-shrink: 0;
}

.status-badge {
    display: inline-block;
    padding: -1px 10px;
    border-radius: 30px;
    font-size: 11px;
    font-weight: 600;
    text-align: left;
}

.status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-approved {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-rejected {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Пагинация для истории */
#historyPagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

#historyPagination button {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px 14px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    min-width: 40px;
}

#historyPagination button:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: var(--primary);
}

#historyPagination button.active {
    background: var(--primary);
    border-color: var(--primary);
}

/* Пригласительные ссылки */
.invite-link-item {
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

.invite-link-item:hover {
    background: rgba(124, 58, 237, 0.05);
}

.invite-link-item code {
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 8px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
}

/* Дополнительные стили для новых элементов */
.loading-spinner {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

.search-loader {
    text-align: center;
    padding: 20px;
    color: var(--primary-light);
}

.channel-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.channel-stats-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    border: 1px solid var(--border-light);
}

.channel-stats-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-light);
}

.channel-stats-label {
    font-size: 12px;
    color: var(--text-muted);
}

/* Анимация для исчезающих сообщений */
@keyframes fadeOutMessage {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.message-row.auto-deleting {
    animation: fadeOutMessage 0.5s ease-out forwards;
    pointer-events: none;
}

/* Адаптация для мобильных */
@media (max-width: 720px) {
    .glass-panel {
        height: 100dvh;
        border-radius: 0;
    }
    .contacts-sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        transform: translateX(-100%);
        background: rgba(15, 10, 25, 0.98);
        backdrop-filter: blur(40px);
        box-shadow: 8px 0 40px rgba(0, 0, 0, 0.3);
        z-index: 50;
        transition: transform 0.28s ease;
    }
    .contacts-sidebar.mobile-open {
        transform: translateX(0);
    }
    .menu-toggle {
        display: flex !important;
    }
    .chat-topbar {
        padding: 12px 16px;
    }
    .touch-id-btn span {
        display: none;
    }
    .touch-id-btn i {
        font-size: 28px;
        margin: 0;
    }
    .touch-id-btn {
        padding: 10px 14px;
    }
    .messages-area {
        padding: 16px 12px;
    }
    .message-input-area {
        padding: 10px 14px;
    }
    .auth-card {
        padding: 34px 24px;
    }
    .message-row {
        max-width: 88%;
    }
    .contact-card {
        padding: 12px 14px;
    }
    .msg-input {
        font-size: 16px;
        padding: 12px 18px;
    }
    .modal-card {
        padding: 24px 20px;
    }
    .pinned-messages-bar {
        padding: 6px 12px;
    }
    .pinned-message-preview {
        font-size: 12px;
        padding: 5px 12px;
    }
    
    /* Мобильное меню Attach */
    #mobileAttachMenu .modal-card {
        max-width: 300px;
        padding: 20px;
    }
    
    #mobileAttachMenu .btn {
        padding: 14px 12px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .contacts-sidebar {
        width: 100%;
    }
    .chat-avatar {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    .chat-name-status h3 {
        font-size: 16px;
    }
    .contact-avatar {
        width: 48px;
        height: 48px;
    }
    .avatar-lg {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    .message-bubble {
        padding: 8px 14px;
        font-size: 14px;
    }
    .send-msg-btn {
        width: 48px;
        height: 48px;
    }
    .attach-btn {
        width: 44px;
        height: 44px;
    }
    .message-row {
        max-width: 92%;
    }
    .history-item {
        flex-wrap: wrap;
        gap: 10px;
    }
    .history-amount {
        min-width: 80px;
        font-size: 14px;
    }
    .history-status {
        min-width: 70px;
        width: 100%;
        text-align: left;
        margin-top: 4px;
    }
    .input-actions-group .icon-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    .poll-option {
        padding: 8px 12px;
        font-size: 13px;
    }
    .mention-suggestions {
        width: 200px;
    }
}