:root {
    --primary-color: #6c5ce7;
    --primary-hover: #5b4cc4;
    --bg-color: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a24;
    --text-primary: #ffffff;
    --text-secondary: #8b8b9a;
    --message-out: #6c5ce7;
    --message-in: #1a1a24;
    --border-color: #1f1f2e;
    --success: #00b894;
    --danger: #d63031;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Auth Styles */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-color) 0%, var(--bg-secondary) 100%);
}

.auth-card {
    background-color: var(--bg-secondary);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border-color);
}

.logo-text {
    font-size: 2rem;
    font-weight: 800;
    text-align: center;
    background: linear-gradient(135deg, var(--primary-color), #a29bfe);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 0.9rem;
}

.input-group {
    margin-bottom: 20px;
}

.input-field {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-field:focus {
    border-color: var(--primary-color);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    width: 100%;
    padding: 12px;
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-secondary:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* Main App Layout */
.app-container {
    height: 100vh;
    min-height: 100vh;
    display: flex;
    width: 100%;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Sidebar */
.sidebar {
    position: relative;
    min-width: 320px;
    width: 320px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.avatar-wrapper {
    position: relative;
    margin-right: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.user-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
    position: absolute;
    bottom: 0;
    right: 0;
}

.status-online { background-color: var(--success); }
.status-away { background-color: #f39c12; }
.status-busy { background-color: var(--danger); }
.status-offline { background-color: #555; }

.sidebar-header button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 1rem;
}

.sidebar-header button:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Search */
.search-bar {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}

.search-input:focus {
    border-color: var(--primary-color);
}

.clear-search-btn {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-search-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.clear-search-btn.hidden {
    display: none;
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.chat-item:hover {
    background-color: var(--bg-tertiary);
}

.chat-item.saved-messages {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-left: 3px solid #667eea;
}

.chat-item.saved-messages:hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
}

.chat-info {
    flex: 1;
    margin-left: 12px;
    min-width: 0;
}

.chat-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.chat-preview {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.chat-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    position: relative;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h2 {
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 0.9rem;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    padding: 16px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.back-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    margin-right: 12px;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.2s;
}

.back-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.header-info {
    flex: 1;
    margin-left: 12px;
}

.header-name {
    font-weight: 600;
    font-size: 1rem;
    display: block;
    margin-bottom: 2px;
}

.header-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-status .user-status {
    margin: 0;
}

.call-buttons {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.call-btn-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.call-btn-small:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: calc(100vh - 120px);
    min-height: 0;
}

/* Date Separator */
.date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px 0;
    position: relative;
}

.date-separator-line {
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.date-separator-text {
    padding: 4px 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 12px;
    margin: 0 12px;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.message {
    position: relative;
    display: flex;
    flex-direction: column;
    max-width: 70%;
    animation: messageSlide 0.2s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.own {
    align-self: flex-end;
}

.message.other {
    align-self: flex-start;
}

.message-content {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.own .message-content {
    background-color: var(--message-out);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.other .message-content {
    background-color: var(--message-in);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 4px;
    padding: 0 4px;
}

.message.own .message-time {
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    padding: 8px 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
    opacity: 0;
    transition: opacity 0.2s;
}

.typing-indicator.visible {
    opacity: 1;
}

/* Chat Input */
.chat-input-area {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    min-height: 58px;
    max-height: 58px;
    height: 58px;
}

.message-input-container {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: nowrap;
    height: 58px;
    min-height: 58px;
}

/* Группа кнопок слева */
.message-input-container > .file-input-container,
.message-input-container > .emoji-btn,
.message-input-container > .gif-btn,
.message-input-container > .format-toggle-btn {
    order: 1;
}

/* Строка ввода в центре */
.chat-input {
    order: 2;
    flex: 1;
    min-width: 0;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    font-family: inherit;
    height: 38px;
    line-height: 38px;
    overflow: hidden;
    box-sizing: border-box;
}

/* Кнопки справа */
.message-input-container > .voice-input-btn,
.message-input-container > .send-btn {
    order: 3;
}

/* Панель кнопок - визуальная группировка */
.message-input-container::before {
    content: '';
    order: 1;
    display: flex;
    align-items: center;
    gap: 2px;
}

.chat-input:focus {
    border-color: var(--primary-color);
}

.format-toggle-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    border-radius: 50%;
    border: none;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.format-toggle-btn:hover,
.format-toggle-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.send-btn, .voice-input-btn, .file-input-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    border-radius: 50%;
    border: none;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:hover, .voice-input-btn:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05);
}

.file-input-btn, .document-input-btn {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
}

.file-input-btn:hover, .document-input-btn:hover {
    background-color: var(--bg-hover);
    color: var(--primary-color);
}

.voice-input-btn.recording {
    background-color: var(--danger);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.file-input-container {
    position: relative;
}

.file-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Voice & Image Messages */
.voice-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 18px;
    min-width: 280px;
    max-width: 350px;
}

.voice-play-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    border: none;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.voice-play-btn:hover {
    background: #5a4fd8;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.4);
}

.voice-play-btn:active {
    transform: scale(0.95);
}

.voice-progress-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}

.voice-waveform {
    height: 24px;
    display: flex;
    align-items: center;
    pointer-events: none;
}

.voice-progress {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    cursor: pointer;
    margin: 0;
    border-radius: 3px;
    position: relative;
    z-index: 10;
}

.voice-progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: grab;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    transition: all 0.2s;
}

.voice-progress::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.2);
}

.voice-progress::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 8px rgba(0,0,0,0.4);
}

.voice-progress::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: grab;
    border: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    transition: all 0.2s;
}

.voice-progress::-moz-range-thumb:active {
    cursor: grabbing;
    transform: scale(1.2);
}

.voice-progress::-moz-range-thumb:hover {
    transform: scale(1.15);
}

.voice-progress::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, 
        var(--primary-color) 0%, 
        var(--primary-color) var(--voice-progress, 0%), 
        rgba(255, 255, 255, 0.1) var(--voice-progress, 0%), 
        rgba(255, 255, 255, 0.1) 100%);
    border-radius: 3px;
}

.voice-progress::-moz-range-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.voice-progress::-moz-range-progress {
    background: var(--primary-color);
    height: 6px;
    border-radius: 3px;
}

.voice-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.voice-time {
    min-width: 35px;
}

.voice-duration {
    color: var(--text-secondary);
    opacity: 0.6;
}

.voice-speed-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.voice-speed-btn:hover {
    background: var(--bg-hover);
    color: var(--primary-color);
}

/* Progress fill effect */
.voice-progress-container::before {
    content: '';
    position: absolute;
    height: 6px;
    background: var(--primary-color);
    border-radius: 3px;
    pointer-events: none;
    width: var(--voice-progress, 0%);
    transition: width 0.1s linear;
}

.voice-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.voice-time {
    font-weight: 600;
    color: var(--text-primary);
}

.voice-duration {
    color: var(--text-secondary);
}

.voice-speed-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.voice-speed-btn:hover {
    background-color: var(--bg-secondary);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.image-message {
    max-width: 300px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
}

.image-message img {
    width: 100%;
    height: auto;
    display: block;
}

/* Sticker Messages (Custom Emoji) */
.sticker-message {
    max-width: 150px;
    cursor: pointer;
    background: transparent;
}

.sticker-image {
    width: 100%;
    height: auto;
    display: block;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* GIF Messages */
.gif-message {
    max-width: 300px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
}

.message-gif {
    width: 100%;
    height: auto;
    display: block;
    max-height: 400px;
    object-fit: contain;
}

/* Search Results */
.search-results-modal {
    position: absolute;
    top: 120px;
    left: 12px;
    right: 12px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-result-item:hover {
    background-color: var(--bg-tertiary);
}

.search-result-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.search-result-phone {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.search-no-results {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Profile Page */
.profile-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
    background-color: var(--bg-color);
    min-height: 100vh;
}

.profile-header {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.profile-header h1 {
    margin-left: 16px;
    font-size: 1.5rem;
}

.profile-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profile-section {
    background-color: var(--bg-secondary);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.profile-section h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.avatar-section {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.large-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.avatar-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-width: 250px;
}

/* Custom File Input */
.file-input-wrapper {
    position: relative;
    width: 100%;
}

.file-input-hidden {
    position: absolute;
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
}

.file-input-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    background-color: var(--bg-tertiary);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.file-input-label:hover {
    background-color: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.file-input-label i {
    font-size: 1.1rem;
}

.file-input-hidden:focus + .file-input-label {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.file-input-label.has-file {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    border-style: solid;
}

.file-input-label.has-file:hover {
    background-color: var(--primary-hover);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 600;
}

.form-group small {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 4px;
}

textarea.input-field {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-danger:hover {
    background-color: #b71c1c;
}

/* ===== RESPONSIVE DESIGN FOR ALL SCREEN SIZES ===== */

/* Ultra Small Screens (320px - 479px) - Mobile Phones */
@media (max-width: 479px) {
    .sidebar {
        position: absolute;
        width: 100%;
        height: 100%;
        min-width: 100%;
        transform: translateX(0);
        transition: transform 0.3s ease;
    }
    
    .chat-area {
        position: absolute;
        width: 100%;
        height: 100%;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 15;
    }
    
    .app-container.chat-active .sidebar {
        transform: translateX(-100%);
    }
    
    .app-container.chat-active .chat-area {
        transform: translateX(0);
    }
    
    .message {
        max-width: 90%;
    }
    
    .sidebar-header {
        padding: 12px;
    }
    
    .chat-header {
        padding: 12px;
    }
    
    .messages-container {
        padding: 12px;
    }
    
    .message-content {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
}

/* Small Tablets (480px - 767px) */
@media (min-width: 480px) and (max-width: 767px) {
    .sidebar {
        position: absolute;
        width: 100%;
        height: 100%;
        min-width: 100%;
        transform: translateX(0);
        transition: transform 0.3s ease;
    }
    
    .chat-area {
        position: absolute;
        width: 100%;
        height: 100%;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 15;
    }
    
    .app-container.chat-active .sidebar {
        transform: translateX(-100%);
    }
    
    .app-container.chat-active .chat-area {
        transform: translateX(0);
    }
    
    .message {
        max-width: 85%;
    }
}

/* Tablets (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .sidebar {
        min-width: 280px;
        width: 280px;
    }
    
    .message {
        max-width: 75%;
    }
    
    .chat-header {
        padding: 14px;
    }
    
    .messages-container {
        padding: 16px;
    }
}

/* Small Laptops (1024px - 1365px) */
@media (min-width: 1024px) and (max-width: 1365px) {
    .sidebar {
        min-width: 300px;
        width: 300px;
    }
    
    .message {
        max-width: 70%;
    }
}

/* Standard Laptops & Desktops (1366px - 1919px) */
@media (min-width: 1366px) and (max-width: 1919px) {
    .sidebar {
        min-width: 320px;
        width: 320px;
    }
    
    .message {
        max-width: 65%;
    }
    
    .messages-container {
        padding: 24px;
    }
}

/* Full HD & 2K Screens (1920px - 2559px) */
@media (min-width: 1920px) and (max-width: 2559px) {
    .sidebar {
        min-width: 360px;
        width: 360px;
    }
    
    .message {
        max-width: 60%;
    }
    
    .messages-container {
        padding: 28px;
        gap: 14px;
    }
    
    .message-content {
        font-size: 1rem;
        padding: 12px 16px;
    }
    
    .chat-header {
        padding: 18px;
    }
    
    .sidebar-header {
        padding: 18px;
    }
}

/* 4K & Ultra Wide Screens (2560px+) */
@media (min-width: 2560px) {
    .sidebar {
        min-width: 400px;
        width: 400px;
    }
    
    .message {
        max-width: 55%;
    }
    
    .messages-container {
        padding: 32px;
        gap: 16px;
    }
    
    .message-content {
        font-size: 1.05rem;
        padding: 14px 18px;
    }
    
    .chat-header {
        padding: 20px;
    }
    
    .sidebar-header {
        padding: 20px;
    }
    
    .chat-name {
        font-size: 1rem;
    }
    
    .header-name {
        font-size: 1.1rem;
    }
}

/* Vertical Monitors (Portrait Orientation) */
@media (max-aspect-ratio: 3/4) {
    .sidebar {
        min-width: 100%;
        width: 100%;
    }
    
    .chat-area {
        display: none;
    }
    
    .app-container.chat-active .sidebar {
        display: none;
    }
    
    .app-container.chat-active .chat-area {
        display: flex;
        width: 100%;
    }
}

/* Ultra Wide Monitors (21:9 and wider) */
@media (min-aspect-ratio: 21/9) {
    .sidebar {
        min-width: 380px;
        width: 380px;
    }
    
    .messages-container {
        max-width: 1400px;
        margin: 0 auto;
    }
}

/* High DPI Screens (Retina, 4K, etc.) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    .avatar, .large-avatar {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
/* Moder
n Call Interface */
.call-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.call-gradient-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    opacity: 0.9;
}

.call-header {
    position: relative;
    z-index: 10001;
    display: flex;
    justify-content: space-between;
    padding: 20px;
    color: white;
}

.call-back-btn, .call-add-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.95rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.call-back-btn:hover, .call-add-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.call-content {
    position: relative;
    z-index: 10001;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.call-avatar-container {
    position: relative;
    margin-bottom: 30px;
}

.call-avatar-circle {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 2;
}

.call-avatar-initials {
    font-size: 4rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.call-avatar-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.8;
    }
}

.call-user-info {
    text-align: center;
    color: white;
}

.call-username {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 12px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.call-status-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1rem;
}

.call-signal-icon {
    font-size: 0.9rem;
}

.call-timer {
    font-weight: 600;
    font-size: 1.1rem;
}

.call-recording-dot {
    font-size: 0.5rem;
    opacity: 0.7;
}

.call-encryption-badge {
    margin-top: 30px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 20px;
    color: white;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.call-controls-bottom {
    position: relative;
    z-index: 10001;
    padding: 30px 20px 40px;
}

.call-incoming-buttons {
    display: flex;
    justify-content: center;
    gap: 60px;
}

.call-btn-round {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.call-btn-decline {
    background: #ff3b30;
    color: white;
}

.call-btn-answer {
    background: #34c759;
    color: white;
}

.call-btn-round:hover {
    transform: scale(1.1);
}

.call-action-buttons {
    display: flex;
    justify-content: space-around;
    max-width: 500px;
    margin: 0 auto;
}

.call-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.call-action-btn span {
    color: white;
    font-size: 0.8rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.call-btn-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.call-btn-circle:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.05);
}

.call-btn-end {
    background: #ff3b30;
}

.call-btn-end:hover {
    background: #e02d22;
}

@media (max-width: 768px) {
    .call-avatar-circle {
        width: 140px;
        height: 140px;
    }
    
    .call-avatar-initials {
        font-size: 3.5rem;
    }
    
    .call-username {
        font-size: 1.8rem;
    }
    
    .call-action-buttons {
        flex-wrap: wrap;
        gap: 20px;
    }
    
    .call-btn-circle {
        width: 55px;
        height: 55px;
        font-size: 1.2rem;
    }
}
/* Mi
nimized Call Window */
.minimized-call {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    animation: slideInFromTop 0.3s ease;
}

@keyframes slideInFromTop {
    from {
        transform: translateY(-100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.minimized-call-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 250px;
}

.minimized-call-content:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
}

.minimized-call-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    animation: pulse-mini 2s ease-in-out infinite;
}

@keyframes pulse-mini {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.minimized-call-info {
    flex: 1;
    color: white;
}

.minimized-call-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.minimized-call-timer {
    font-size: 0.85rem;
    opacity: 0.9;
}

.minimized-call-end {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 59, 48, 0.9);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.minimized-call-end:hover {
    background: #ff3b30;
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .minimized-call {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    
    .minimized-call-content {
        min-width: auto;
    }
}
/* Me
ssage Status Icons */
.message-status {
    margin-left: 4px;
    font-size: 0.7rem;
    opacity: 0.7;
}

.message-status[data-status="sending"] {
    color: var(--text-secondary);
}

.message-status[data-status="sent"] {
    color: var(--text-secondary);
}

.message-status[data-status="delivered"] {
    color: var(--text-secondary);
}

.message-status[data-status="read"] {
    color: var(--primary-color);
}

.message-time {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ===== SETTINGS PAGE ===== */
.settings-container {
    display: flex;
    height: 100vh;
    background: var(--bg-color);
}

.settings-sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.settings-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 15px;
}

.settings-header .back-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.settings-header .back-btn:hover {
    background: var(--bg-tertiary);
}

.settings-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    flex: 1;
}

.settings-header .close-settings-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    margin-left: auto;
}

.settings-header .close-settings-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.settings-menu {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
}

.settings-menu-item {
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.settings-menu-item i {
    font-size: 1.1rem;
    width: 24px;
}

.settings-menu-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.settings-menu-item.active {
    background: var(--primary-color);
    color: white;
}

.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
}

.settings-section {
    display: none;
    max-width: 700px;
    animation: fadeIn 0.3s ease;
}

.settings-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-title {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 30px;
    color: var(--text-primary);
}

.settings-group {
    margin-bottom: 30px;
}

.settings-label {
    display: block;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.settings-hint {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

.settings-input,
.settings-textarea,
.settings-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: var(--font-family);
    transition: border-color 0.2s;
}

.settings-input:focus,
.settings-textarea:focus,
.settings-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.settings-textarea {
    resize: vertical;
    min-height: 100px;
}

.settings-input[readonly] {
    background: var(--bg-secondary);
    cursor: not-allowed;
    color: var(--text-secondary);
}

/* Avatar Upload */
.avatar-upload {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
}

.avatar-preview {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border-color);
}

.avatar-upload-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 3px solid var(--bg-secondary);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.avatar-upload-btn:hover {
    background: var(--primary-hover);
}

/* Toggle Switch */
.settings-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}

.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: var(--bg-tertiary);
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* Theme Selector */
.theme-selector {
    display: flex;
    gap: 12px;
}

.theme-option {
    flex: 1;
    padding: 16px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.theme-option i {
    font-size: 1.5rem;
}

.theme-option:hover {
    border-color: var(--primary-color);
    background: var(--bg-secondary);
}

.theme-option.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

/* Font Size Selector */
.font-size-selector {
    display: flex;
    gap: 12px;
}

.font-size-option {
    width: 60px;
    height: 60px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.font-size-option[data-size="small"] {
    font-size: 0.9rem;
}

.font-size-option[data-size="medium"] {
    font-size: 1.1rem;
}

.font-size-option[data-size="large"] {
    font-size: 1.3rem;
}

.font-size-option:hover {
    border-color: var(--primary-color);
}

.font-size-option.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

/* Color Selector */
.color-selector {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.color-option {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: white;
    box-shadow: 0 0 0 2px var(--bg-color);
}

.color-option.active::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 1.2rem;
}

/* Wallpaper Grid */
.wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.wallpaper-item {
    aspect-ratio: 16/9;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
    position: relative;
}

.wallpaper-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wallpaper-item:hover {
    transform: scale(1.05);
    border-color: var(--primary-color);
}

.wallpaper-item.active {
    border-color: var(--primary-color);
}

.wallpaper-item.active::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.9rem;
}

/* Light Theme */
body.light-theme {
    --bg-color: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8e8;
    --text-primary: #000000;
    --text-secondary: #666666;
    --message-out: #6c5ce7;
    --message-in: #ffffff;
    --border-color: #e0e0e0;
}

/* Animations Disabled */
body.no-animations * {
    animation: none !important;
    transition: none !important;
}

/* Font Sizes */
body.font-small {
    font-size: 14px;
}

body.font-medium {
    font-size: 16px;
}

body.font-large {
    font-size: 18px;
}

/* Responsive */
@media (max-width: 768px) {
    .settings-container {
        flex-direction: column;
    }
    
    .settings-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .settings-menu {
        display: flex;
        overflow-x: auto;
        padding: 10px;
    }
    
    .settings-menu-item {
        flex-direction: column;
        min-width: 80px;
        text-align: center;
    }
    
    .settings-content {
        padding: 20px;
    }
}


/* ===== MESSAGE FORMATTING ===== */

/* Allow text selection in messages */
.message-content {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    cursor: text;
}

/* Formatted text styles */
.message-content strong {
    font-weight: 700;
}

.message-content em {
    font-style: italic;
}

.message-content s {
    text-decoration: line-through;
    opacity: 0.7;
}

.message-content u {
    text-decoration: underline;
}

.message-content .inline-code {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-content .message-link {
    color: #4a9eff;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.message-content .message-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Context Menu */
.message-context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 6px;
    min-width: 200px;
    z-index: 10000;
    animation: contextMenuAppear 0.15s ease;
}

@keyframes contextMenuAppear {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.message-context-menu.hidden {
    display: none;
}

.context-menu-item {
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.context-menu-item:hover {
    background: var(--bg-tertiary);
}

.context-menu-item.danger {
    color: var(--danger);
}

.context-menu-item.danger:hover {
    background: rgba(214, 48, 49, 0.1);
}

.context-menu-item i {
    width: 18px;
    text-align: center;
}

.context-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 6px 0;
}

/* Message Selection */
.message.selected {
    background: rgba(108, 92, 231, 0.1);
    border-left: 3px solid var(--primary-color);
    padding-left: 9px;
}

.message.selected::before {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: -25px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: white;
}

/* Selection Toolbar */
.selection-toolbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 9999;
    animation: toolbarSlideUp 0.3s ease;
}

@keyframes toolbarSlideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.toolbar-btn {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: var(--primary-color);
    color: white;
}

.toolbar-btn.danger {
    color: var(--danger);
}

.toolbar-btn.danger:hover {
    background: var(--danger);
    color: white;
}

.toolbar-count {
    padding: 0 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    border-left: 1px solid var(--border-color);
    margin-left: 8px;
}

/* Reply Bar - Telegram style */
.reply-bar {
    background: var(--bg-secondary);
    padding: 8px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.reply-bar:hover {
    background: var(--bg-tertiary);
}

.reply-content {
    display: flex;
    align-items: stretch;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.reply-line {
    width: 3px;
    background: var(--primary-color);
    border-radius: 2px;
    flex-shrink: 0;
}

.reply-text {
    flex: 1;
    min-width: 0;
}

.reply-label {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 2px;
}

.reply-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reply-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.reply-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Highlight animation for scrolled message */
.message.highlight {
    animation: highlight 2s ease;
}

@keyframes highlight {
    0%, 100% {
        background: transparent;
    }
    50% {
        background: rgba(108, 92, 231, 0.2);
    }
}

.reply-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Formatting Toolbar (for input) */
.formatting-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.format-btn {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.format-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.format-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .selection-toolbar {
        bottom: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        flex-wrap: wrap;
    }
    
    .toolbar-btn span {
        display: none;
    }
    
    .message-context-menu {
        min-width: 180px;
    }
}


/* ===== FILE MESSAGES ===== */

.document-input-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
}

.document-input-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

/* File Message */
.file-message {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 250px;
    max-width: 350px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.file-message:hover {
    background: var(--bg-secondary);
}

/* Превью файла с кнопкой загрузки */
.file-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.95), rgba(108, 92, 231, 0.85));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.file-preview-overlay:hover {
    background: linear-gradient(135deg, rgba(108, 92, 231, 1), rgba(108, 92, 231, 0.95));
}

.file-preview-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    text-align: center;
}

.file-preview-overlay .file-icon {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.file-preview-overlay .file-info {
    color: white;
}

.file-preview-overlay .file-name {
    color: white;
    font-size: 0.85rem;
}

.file-preview-overlay .file-size {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
}

.file-load-prompt {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.file-load-prompt i {
    font-size: 1rem;
}

.file-loaded-content {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.file-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    flex-shrink: 0;
}

.file-icon.pdf {
    background: #e74c3c;
}

.file-icon.doc {
    background: #3498db;
}

.file-icon.xls {
    background: #27ae60;
}

.file-icon.zip {
    background: #f39c12;
}

.file-icon.video {
    background: #9b59b6;
}

.file-icon.audio {
    background: #1abc9c;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 4px;
}

.file-size {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.file-download-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.file-download-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

/* Edit Message */
.edit-message-bar {
    background: var(--bg-tertiary);
    border-left: 3px solid #f39c12;
    padding: 12px 16px;
    margin-bottom: 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.edit-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.edit-content i {
    color: #f39c12;
    font-size: 1.2rem;
}

.edit-text {
    flex: 1;
}

.edit-label {
    font-size: 0.8rem;
    color: #f39c12;
    font-weight: 600;
    margin-bottom: 4px;
}

.edit-message-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.edit-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.edit-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.message.edited::after {
    content: 'изменено';
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 6px;
    font-style: italic;
}

/* File Upload Progress */
.upload-progress {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    min-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.upload-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.upload-progress-title {
    font-weight: 600;
    color: var(--text-primary);
}

.upload-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.upload-progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.upload-progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}


/* ===== PINNED CHATS ===== */

.chat-item.pinned {
    background: linear-gradient(90deg, rgba(108, 92, 231, 0.05) 0%, transparent 100%);
    border-left: 3px solid var(--primary-color);
}

.pin-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    color: var(--primary-color);
    font-size: 0.8rem;
    transform: rotate(45deg);
}

/* ===== DRAG AND DROP ===== */

.chat-area.drag-over {
    background: rgba(108, 92, 231, 0.05);
    border: 2px dashed var(--primary-color);
}

.drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.drag-overlay-content {
    background: var(--bg-secondary);
    border: 3px dashed var(--primary-color);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
}

.drag-overlay-icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.drag-overlay-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== FILE PREVIEW MODAL ===== */

.file-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.file-preview-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.file-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.file-preview-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.file-preview-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.file-preview-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.file-preview-body {
    margin-bottom: 20px;
}

.file-preview-image {
    width: 100%;
    border-radius: 12px;
    margin-bottom: 16px;
}

.file-preview-info {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.file-preview-info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.file-preview-info-row:last-child {
    border-bottom: none;
}

.file-preview-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.file-preview-value {
    color: var(--text-primary);
    font-weight: 600;
}

.file-caption-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
}

.file-caption-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.file-preview-actions {
    display: flex;
    gap: 12px;
}

.file-preview-actions button {
    flex: 1;
}


/* ===== COPY NOTIFICATION ===== */

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
}

/* ===== TEXT SELECTION ===== */

.message-content::selection {
    background: var(--primary-color);
    color: white;
}

.message-content::-moz-selection {
    background: var(--primary-color);
    color: white;
}

/* Allow text selection */
.message-content {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    cursor: text !important;
}

/* Selection mode */
.selection-mode .message {
    cursor: pointer;
    transition: all 0.2s;
}

.selection-mode .message:hover {
    background: rgba(108, 92, 231, 0.05);
}


/* Selection mode */
.selection-mode-active .message {
    padding-left: 50px;
    position: relative;
}

.selection-mode-active .message-checkbox {
    display: block !important;
}

.message-checkbox {
    display: none;
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.message.selected {
    background: rgba(108, 92, 231, 0.1);
}

.selection-toolbar {
    display: none;
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    padding: 12px 24px;
    border-radius: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    gap: 16px;
    align-items: center;
    z-index: 1000;
}

.selection-toolbar.visible {
    display: flex;
}

.selection-toolbar button {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 8px;
    transition: background 0.2s;
}

.selection-toolbar button:hover {
    background: var(--bg-hover);
}

.selection-toolbar .count {
    color: var(--primary-color);
    font-weight: 600;
}

/* Status indicators */
.status-online {
    background: #10b981;
}

.status-offline {
    background: #6b7280;
}

.status-typing {
    background: var(--primary-color);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Typing indicator */
.typing-indicator {
    opacity: 0;
    transition: opacity 0.3s;
    height: 0;
    overflow: hidden;
}

.typing-indicator.visible {
    opacity: 1;
    height: auto;
    padding: 8px 16px;
}


/* Emoji and GIF buttons */
.emoji-btn, .gif-btn, .file-input-btn, .document-input-btn {
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 1rem;
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.emoji-btn:hover, .gif-btn:hover, .file-input-btn:hover, .document-input-btn:hover {
    background: var(--bg-hover);
    color: var(--primary-color);
}

/* Группа кнопок слева - визуальная панель */
.message-input-container > .file-input-container:first-of-type,
.message-input-container > .file-input-container:nth-of-type(2),
.message-input-container > .emoji-btn,
.message-input-container > .gif-btn,
.message-input-container > .format-toggle-btn {
    margin-right: 0;
}

/* Создаём визуальную группу */
.message-input-container > .file-input-container:first-of-type .file-input-btn,
.message-input-container > .file-input-container:first-of-type .document-input-btn {
    border-radius: 8px 0 0 8px;
}

.message-input-container > .format-toggle-btn {
    border-radius: 0 8px 8px 0;
    margin-right: 8px;
}

/* Emoji Picker */
.emoji-picker {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 400px;
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
}

.emoji-picker.hidden {
    display: none;
}

.emoji-picker-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.emoji-search {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.emoji-categories {
    display: flex;
    gap: 4px;
    overflow-x: auto;
}

.emoji-category {
    background: none;
    border: none;
    font-size: 1.5rem;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.emoji-category:hover {
    background: var(--bg-hover);
}

.emoji-category.active {
    background: var(--primary-color);
}

.emoji-picker-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    align-content: start;
}

.emoji-item {
    font-size: 1.8rem;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    text-align: center;
}

.emoji-item:hover {
    background: var(--bg-hover);
    transform: scale(1.2);
}

/* GIF Picker */
.gif-picker {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 400px;
    height: 500px;
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
}

.gif-picker.hidden {
    display: none;
}

.gif-picker-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    align-items: center;
}

.gif-search {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
}

.gif-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.gif-close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.gif-picker-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    align-content: start;
}

.gif-item {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.gif-item:hover {
    transform: scale(1.05);
}

.gif-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* GIF in messages */
.gif-message {
    display: inline-block;
    max-width: 100%;
}

.message-gif {
    max-width: 320px;
    max-height: 320px;
    width: auto;
    height: auto;
    border-radius: 12px;
    cursor: pointer;
    display: block;
    object-fit: contain;
    background: var(--bg-tertiary);
}

.message-gif:hover {
    opacity: 0.95;
}

/* GIF loading animation */
.message-gif[src=""] {
    min-width: 200px;
    min-height: 200px;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}


/* Message Reactions - Telegram style - REMOVED DUPLICATE */

/* Quick reaction button on message hover */
.message:hover .quick-reaction-btn {
    opacity: 1;
}

.quick-reaction-btn {
    position: absolute;
    top: -12px;
    right: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.quick-reaction-btn:hover {
    background: var(--bg-hover);
    transform: scale(1.1);
}

.quick-reaction-btn i {
    font-size: 1rem;
    color: var(--text-secondary);
}


/* Settings logout button */
.settings-menu-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.settings-menu-item.danger {
    color: #ef4444;
}

.settings-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.settings-menu-item.danger i {
    color: #ef4444;
}

/* Logout confirmation modal */
.logout-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.logout-modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
}

.logout-modal-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.logout-modal-text {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.logout-modal-warning {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid #ef4444;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.logout-modal-warning-title {
    color: #ef4444;
    font-weight: 600;
    margin-bottom: 4px;
}

.logout-modal-warning-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.logout-modal-actions {
    display: flex;
    gap: 12px;
}

.logout-modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-cancel-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.logout-cancel-btn:hover {
    background: var(--bg-hover);
}

.logout-confirm-btn {
    background: #ef4444;
    color: white;
}

.logout-confirm-btn:hover {
    background: #dc2626;
}


/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 20px;
    width: 350px;
    height: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.emoji-picker.hidden {
    display: none;
}

.emoji-picker-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.emoji-search {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    margin-bottom: 8px;
}

.emoji-search:focus {
    border-color: var(--primary-color);
}

.emoji-categories {
    display: flex;
    gap: 4px;
    overflow-x: auto;
}

.emoji-category {
    background: none;
    border: none;
    font-size: 1.3rem;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.emoji-category:hover {
    background: var(--bg-tertiary);
}

.emoji-category.active {
    background: var(--primary-color);
}

.emoji-picker-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    align-content: start;
}

.emoji-item {
    font-size: 1.5rem;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    text-align: center;
    transition: background 0.2s;
}

.emoji-item:hover {
    background: var(--bg-tertiary);
}

/* GIF Picker */
.gif-picker {
    position: absolute;
    bottom: 70px;
    left: 20px;
    width: 400px;
    height: 450px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.gif-picker.hidden {
    display: none;
}

.gif-picker-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.gif-search {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}

.gif-search:focus {
    border-color: var(--primary-color);
}

.gif-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.gif-close-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.gif-picker-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    align-content: start;
}

.gif-item {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.gif-item:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.gif-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}


/* ========================================
   МОБИЛЬНАЯ АДАПТАЦИЯ
   ======================================== */

/* Десктоп и планшеты (900px+) */
@media (min-width: 900px) {
    .sidebar {
        width: 380px;
        min-width: 380px;
    }
    
    .back-btn {
        display: none !important;
    }
}

/* Средние планшеты (600px - 899px) */
@media (min-width: 600px) and (max-width: 899px) {
    .sidebar {
        width: 320px;
        min-width: 320px;
    }
    
    .back-btn {
        display: none !important;
    }
    
    .message {
        max-width: 80%;
    }
}

/* Маленькие планшеты и большие телефоны (480px - 599px) */
@media (min-width: 480px) and (max-width: 599px) {
    .sidebar {
        width: 280px;
        min-width: 280px;
    }
    
    .back-btn {
        display: none !important;
    }
    
    .message {
        max-width: 85%;
    }
    
    .chat-header {
        padding: 12px 16px;
    }
}

/* МОБИЛЬНЫЕ ТЕЛЕФОНЫ (до 480px) - режим одного экрана */
@media (max-width: 479px) {
    /* Основной контейнер */
    .app-container {
        position: relative;
        overflow: hidden;
    }
    
    /* Сайдбар на весь экран */
    .sidebar {
        width: 100%;
        max-width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10;
        transition: transform 0.3s ease;
    }
    
    /* Скрываем сайдбар когда открыт чат */
    .sidebar.hidden-mobile {
        transform: translateX(-100%);
    }
    
    /* Чат на весь экран */
    .chat-area {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 11;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    
    /* Показываем чат когда он активен */
    .chat-area.active {
        transform: translateX(0);
    }
    
    /* Показываем кнопку "Назад" */
    .back-btn {
        display: flex !important;
    }
    
    /* Компактный header */
    .chat-header {
        padding: 8px 10px;
        min-height: 50px;
    }
    
    .header-name {
        font-size: 0.9rem;
        font-weight: 600;
    }
    
    .header-status {
        font-size: 0.7rem;
    }
    
    .header-avatar {
        width: 36px;
        height: 36px;
    }
    
    /* Контейнер сообщений */
    .messages-container {
        padding: 8px 10px;
    }
    
    /* Компактные сообщения */
    .message {
        max-width: 80%;
        font-size: 0.85rem;
        margin-bottom: 6px;
    }
    
    .message-content {
        padding: 7px 10px;
        border-radius: 10px;
        word-wrap: break-word;
        word-break: break-word;
        line-height: 1.4;
    }
    
    .message-time {
        font-size: 0.65rem;
        margin-top: 2px;
        padding: 0 4px;
    }
    
    /* Изображения и медиа в сообщениях */
    .message-media,
    .image-message,
    .video-message,
    .gif-message {
        max-width: 100%;
    }
    
    .message-media img,
    .message-media video {
        max-width: 100%;
        max-height: 250px;
        border-radius: 8px;
    }
    
    /* Компактное поле ввода */
    .message-input-container {
        padding: 8px 10px;
        gap: 3px;
    }
    
    .chat-input {
        font-size: 0.85rem;
        padding: 7px 10px;
        min-height: 34px;
        max-height: 120px;
        line-height: 1.4;
        border-radius: 18px;
    }
    
    /* Кнопки в поле ввода */
    .send-btn,
    .attach-btn,
    .emoji-btn,
    .voice-input-btn,
    .format-toggle-btn,
    .gif-btn,
    #attach-btn,
    #emoji-btn,
    #voice-input-btn,
    #send-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        font-size: 0.9rem;
        padding: 0;
        flex-shrink: 0;
    }
    
    /* Скрываем некоторые кнопки на очень маленьких экранах */
    @media (max-width: 360px) {
        #emoji-btn {
            display: none;
        }
    }
    
    /* Компактный список чатов */
    .chat-item {
        padding: 8px 10px;
        min-height: 60px;
    }
    
    .chat-avatar {
        width: 44px;
        height: 44px;
    }
    
    .chat-name {
        font-size: 0.85rem;
        font-weight: 600;
    }
    
    .chat-last-message {
        font-size: 0.75rem;
        line-height: 1.3;
    }
    
    .chat-time {
        font-size: 0.65rem;
    }
    
    /* Компактный header сайдбара */
    .sidebar-header {
        padding: 10px 12px;
        min-height: 56px;
    }
    
    .logo-text {
        font-size: 1.1rem;
    }
    
    /* Аватар в сайдбаре */
    .avatar-wrapper .avatar,
    #my-avatar {
        width: 36px;
        height: 36px;
    }
    
    /* Поиск */
    .search-bar {
        padding: 6px 10px;
        margin: 8px 10px;
    }
    
    .search-bar input {
        font-size: 0.85rem;
        padding: 6px 10px;
    }
    
    /* Реакции */
    .message-reaction-btn {
        width: 24px;
        height: 24px;
        top: -10px;
    }
    
    .message-reaction-btn i {
        font-size: 0.8rem;
    }
    
    .message-reactions {
        gap: 4px;
        margin-top: 4px;
    }
    
    .message-reaction {
        padding: 4px 8px;
        font-size: 0.85rem;
    }
    
    .reaction-emoji {
        font-size: 1.1rem;
    }
    
    .reaction-count {
        font-size: 0.75rem;
    }
    
    /* Скрываем empty-state когда чат не выбран */
    #empty-state {
        display: none !important;
    }
    
    /* Форматирование текста */
    .formatting-toolbar {
        padding: 6px;
        gap: 4px;
    }
    
    .format-btn {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
}

/* СУПЕР МАЛЕНЬКИЕ ЭКРАНЫ (до 360px) */
@media (max-width: 360px) {
    /* Ещё более компактный header */
    .chat-header {
        padding: 6px 8px;
        min-height: 48px;
    }
    
    .header-name {
        font-size: 0.85rem;
    }
    
    .header-status {
        font-size: 0.65rem;
    }
    
    .header-avatar {
        width: 32px;
        height: 32px;
    }
    
    /* Супер компактные сообщения */
    .message {
        max-width: 85%;
        font-size: 0.8rem;
    }
    
    .message-content {
        padding: 6px 9px;
    }
    
    .message-time {
        font-size: 0.6rem;
    }
    
    /* Супер компактное поле ввода */
    .message-input-container {
        padding: 6px 8px;
        gap: 2px;
    }
    
    .chat-input {
        font-size: 0.8rem;
        padding: 6px 9px;
        min-height: 30px;
    }
    
    /* Минимальные кнопки */
    .send-btn,
    .attach-btn,
    .emoji-btn,
    .voice-input-btn,
    .format-toggle-btn,
    .gif-btn,
    #attach-btn,
    #voice-input-btn,
    #send-btn {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
        font-size: 0.85rem;
    }
    
    /* Скрываем некоторые кнопки */
    #emoji-btn,
    .format-toggle-btn {
        display: none !important;
    }
    
    /* Компактный список чатов */
    .chat-item {
        padding: 6px 8px;
        min-height: 56px;
    }
    
    .chat-avatar {
        width: 40px;
        height: 40px;
    }
    
    .chat-name {
        font-size: 0.8rem;
    }
    
    .chat-last-message {
        font-size: 0.7rem;
    }
    
    .chat-time {
        font-size: 0.6rem;
    }
    
    /* Компактный сайдбар */
    .sidebar-header {
        padding: 8px 10px;
        min-height: 52px;
    }
    
    .logo-text {
        font-size: 1rem;
    }
    
    .avatar-wrapper .avatar,
    #my-avatar {
        width: 32px;
        height: 32px;
    }
    
    /* Поиск */
    .search-bar {
        padding: 5px 8px;
        margin: 6px 8px;
    }
    
    .search-bar input {
        font-size: 0.8rem;
        padding: 5px 8px;
    }
    
    /* Медиа в сообщениях */
    .message-media img,
    .message-media video {
        max-height: 200px;
    }
    
    /* Реакции */
    .message-reactions {
        gap: 3px;
        margin-top: 3px;
    }
    
    .message-reaction {
        padding: 3px 6px;
        font-size: 0.8rem;
    }
    
    .reaction-emoji {
        font-size: 1rem;
    }
    
    .reaction-count {
        font-size: 0.7rem;
    }
}

/* Ландшафтная ориентация на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
    .emoji-picker,
    .gif-picker {
        height: 250px;
    }

    .call-avatar {
        width: 60px;
        height: 60px;
    }
}

/* Планшеты */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 320px;
    }

    .message {
        max-width: 70%;
    }

    .emoji-picker,
    .gif-picker {
        width: 380px;
    }
}


/* ========================================
   ДОПОЛНИТЕЛЬНАЯ АДАПТАЦИЯ ДЛЯ МАЛЕНЬКИХ ЭКРАНОВ
   ======================================== */

/* Очень маленькие экраны (до 360px) */
@media (max-width: 360px) {
    /* Уменьшаем отступы */
    .app-container {
        padding: 0;
    }
    
    .chat-header {
        padding: 8px 10px;
        min-height: 50px;
    }
    
    .header-user-info h3 {
        font-size: 0.9rem;
    }
    
    .header-user-info p {
        font-size: 0.75rem;
    }
    
    /* Кнопки в шапке */
    .call-buttons {
        gap: 5px;
    }
    
    .call-btn-small {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
    
    /* Сообщения */
    .message {
        max-width: 85%;
        font-size: 0.85rem;
        padding: 8px 10px;
    }
    
    .message-time {
        font-size: 0.65rem;
    }
    
    /* Поле ввода */
    .message-input-container {
        padding: 8px;
        gap: 6px;
    }
    
    #message-input {
        font-size: 0.9rem;
        padding: 8px 10px;
    }
    
    .send-btn,
    .voice-input-btn {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    /* Список чатов */
    .chat-item {
        padding: 10px;
    }
    
    .chat-avatar {
        width: 40px;
        height: 40px;
    }
    
    .chat-name {
        font-size: 0.9rem;
    }
    
    .chat-last-message {
        font-size: 0.75rem;
    }
    
    /* Модальные окна */
    .modal-content {
        width: 95%;
        max-width: 95%;
        padding: 15px;
    }
    
    .modal-header h2 {
        font-size: 1.1rem;
    }
    
    /* Эмодзи и GIF пикеры */
    .emoji-picker,
    .gif-picker {
        width: 100%;
        height: 300px;
        max-height: 50vh;
    }
    
    .emoji-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 4px;
    }
    
    .emoji-item {
        font-size: 1.5rem;
        padding: 6px;
    }
    
    /* Звонки */
    .call-overlay {
        padding: 10px;
    }
    
    .call-avatar-circle {
        width: 100px;
        height: 100px;
    }
    
    .call-name {
        font-size: 1.1rem;
    }
    
    .call-status {
        font-size: 0.85rem;
    }
    
    .call-action-buttons {
        gap: 10px;
    }
    
    .call-btn-circle {
        width: 50px;
        height: 50px;
        font-size: 1.1rem;
    }
    
    .call-action-label {
        font-size: 0.7rem;
    }
    
    /* Поиск */
    .search-bar input {
        font-size: 0.85rem;
        padding: 8px 35px 8px 10px;
    }
    
    /* Профиль */
    .profile-avatar {
        width: 80px;
        height: 80px;
    }
    
    .profile-name {
        font-size: 1.2rem;
    }
}

/* Исправление переполнения текста */
@media (max-width: 768px) {
    /* Предотвращаем переполнение */
    * {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Ограничиваем ширину контента */
    .message-content,
    .chat-name,
    .chat-last-message,
    .header-user-info h3 {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Изображения и медиа */
    img,
    video {
        max-width: 100%;
        height: auto;
    }
    
    /* Кнопки */
    button {
        min-width: 0;
        white-space: nowrap;
    }
    
    /* Модальные окна на весь экран */
    .emoji-picker,
    .gif-picker,
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Скрываем скроллбар но оставляем прокрутку */
    .emoji-picker::-webkit-scrollbar,
    .gif-picker::-webkit-scrollbar {
        width: 4px;
    }
    
    /* Улучшаем touch targets */
    button,
    a,
    .chat-item,
    .emoji-item {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Увеличиваем размер кликабельных элементов */
    .message-actions button {
        padding: 8px;
        font-size: 1rem;
    }
}

/* Горизонтальная ориентация на маленьких экранах */
@media (max-width: 768px) and (orientation: landscape) {
    .call-overlay {
        padding: 5px;
    }
    
    .call-avatar-circle {
        width: 80px;
        height: 80px;
    }
    
    .call-name {
        font-size: 1rem;
    }
    
    .call-action-buttons {
        flex-direction: row;
        gap: 15px;
    }
    
    .emoji-picker,
    .gif-picker {
        height: 250px;
    }
}

/* Улучшение для iPhone SE и подобных */
@media (max-width: 375px) {
    .sidebar {
        width: 100%;
    }
    
    .chat-header {
        flex-wrap: nowrap;
    }
    
    .header-actions {
        gap: 4px;
    }
    
    .message-input-container {
        gap: 4px;
    }
    
    /* Компактные кнопки */
    .format-btn,
    .attach-btn {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
}

/* Улучшение для складных телефонов */
@media (max-width: 280px) {
    .logo-text {
        font-size: 1.2rem;
    }
    
    .message {
        font-size: 0.8rem;
        padding: 6px 8px;
    }
    
    .chat-item {
        padding: 8px;
    }
    
    .chat-avatar {
        width: 35px;
        height: 35px;
    }
    
    .call-btn-circle {
        width: 45px;
        height: 45px;
    }
}


/* ========================================
   КАСТОМНЫЕ УВЕДОМЛЕНИЯ (КАК В TELEGRAM)
   ======================================== */

.custom-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 360px;
    max-width: calc(100vw - 40px);
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 12px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    z-index: 10000;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: slideInRight 0.3s ease;
    border: 1px solid var(--border-color);
}

.custom-notification:hover {
    transform: translateX(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.custom-notification.closing {
    animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.custom-notification-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.custom-notification-content {
    flex: 1;
    min-width: 0;
}

.custom-notification-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.custom-notification-app {
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.custom-notification-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.custom-notification-sender {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-notification-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.custom-notification-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: none;
    color: var(--text-secondary);
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
}

.custom-notification:hover .custom-notification-close {
    opacity: 1;
}

.custom-notification-close:hover {
    background: var(--danger);
    color: white;
}

/* Стек уведомлений */
.custom-notification:nth-child(2) {
    top: 110px;
}

.custom-notification:nth-child(3) {
    top: 200px;
}

.custom-notification:nth-child(4) {
    top: 290px;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .custom-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
    }
    
    .custom-notification:nth-child(2),
    .custom-notification:nth-child(3),
    .custom-notification:nth-child(4) {
        display: none; /* На мобильных показываем только одно уведомление */
    }
}

/* Темная тема */
@media (prefers-color-scheme: dark) {
    .custom-notification {
        background: #2b2b2b;
        border-color: #3a3a3a;
    }
}

/* ========================================
   MEDIA VIEWER - Просмотр фото/видео
   ======================================== */

.media-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.media-viewer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.media-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    position: relative;
    z-index: 10001;
}

.media-viewer-close,
.media-viewer-download {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
}

.media-viewer-close:hover,
.media-viewer-download:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.media-viewer-counter {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.media-viewer-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.media-viewer-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    transition: transform 0.3s ease;
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
}

.media-viewer-image:active {
    cursor: grabbing;
}

.media-viewer-video {
    max-width: 90%;
    max-height: 90%;
    outline: none;
}

.media-viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.2s ease;
    z-index: 10001;
}

.media-viewer-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.media-viewer-prev {
    left: 20px;
}

.media-viewer-next {
    right: 20px;
}

/* Стили для сообщений с медиа */
.message-media {
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.message-media:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.message-media::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    transition: all 0.2s ease;
    pointer-events: none;
}

.message-media:hover::after {
    background: rgba(0, 0, 0, 0.1);
}

/* Индикатор загрузки для изображений */
.image-message,
.gif-message {
    position: relative;
    display: inline-block;
    min-width: 200px;
    min-height: 150px;
}

.image-loading-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    min-height: 150px;
}

.image-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(108, 92, 231, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    padding: 0 16px;
    opacity: 0.8;
}

.image-loading-placeholder .loading-text {
    color: var(--text-primary);
}

.video-thumbnail-loading .loading-text {
    color: white;
    margin-top: 8px;
}

/* Иконка воспроизведения для видео */
.video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    pointer-events: none;
    transition: all 0.2s ease;
}

.message-media:hover .video-play-icon {
    background: rgba(0, 0, 0, 0.8);
    transform: translate(-50%, -50%) scale(1.1);
}

.video-message {
    position: relative;
    display: inline-block;
}

/* Индикатор загрузки для превью видео */
.video-thumbnail-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    z-index: 1;
}

.video-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .media-viewer-header {
        padding: 15px;
    }
    
    .media-viewer-close,
    .media-viewer-download {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .media-viewer-counter {
        font-size: 14px;
    }
    
    .media-viewer-image,
    .media-viewer-video {
        max-width: 95%;
        max-height: 85%;
    }
    
    .media-viewer-nav {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .media-viewer-prev {
        left: 10px;
    }
    
    .media-viewer-next {
        right: 10px;
    }
    
    .video-play-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .media-viewer-header {
        padding: 10px;
    }
    
    .media-viewer-nav {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    
    .media-viewer-image,
    .media-viewer-video {
        max-width: 98%;
        max-height: 80%;
    }
}

/* Анимации */
@keyframes mediaFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.media-viewer-image,
.media-viewer-video {
    animation: mediaFadeIn 0.3s ease;
}

/* Индикатор загрузки */
.media-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    color: white;
}

.media-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.media-loading-text {
    font-size: 16px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

/* Ошибка загрузки */
.media-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
}

.media-error i {
    font-size: 48px;
    color: #ff6b6b;
}

/* Мобильная адаптация для загрузки */
@media (max-width: 768px) {
    .media-spinner {
        width: 50px;
        height: 50px;
        border-width: 3px;
    }
    
    .media-loading-text {
        font-size: 14px;
    }
    
    .media-error {
        font-size: 14px;
    }
    
    .media-error i {
        font-size: 40px;
    }
}

/* ========================================
   FILE CONTEXT MENU & FORWARD
   ======================================== */

/* Контекстное меню для файлов и сообщений (черный стиль) */
.file-context-menu {
    position: fixed;
    background: #1c1c1e;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    padding: 6px 0;
    z-index: 10000;
    min-width: 220px;
    border: 0.5px solid rgba(255, 255, 255, 0.08);
}

.context-menu-item {
    padding: 13px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: all 0.15s;
    color: #ffffff;
}

.context-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.context-menu-item:active {
    background: rgba(255, 255, 255, 0.12);
}

.context-menu-item i {
    width: 22px;
    color: #ffffff;
    font-size: 17px;
    opacity: 0.9;
}

.context-menu-item span {
    font-size: 15px;
    color: #ffffff;
    font-weight: 400;
    letter-spacing: -0.2px;
}

/* Кнопка скачивания в файле */
.file-download-btn {
    background: rgba(108, 92, 231, 0.1);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--primary-color);
}

.file-download-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

/* Модальное окно пересылки */
.forward-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.forward-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.forward-modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.forward-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.forward-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.forward-modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.forward-modal-body {
    padding: 20px;
    overflow-y: auto;
}

.forward-file-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(108, 92, 231, 0.05);
    border-radius: 8px;
    margin-bottom: 20px;
}

.forward-file-preview i {
    font-size: 24px;
    color: var(--primary-color);
}

.forward-file-preview span {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.forward-chats-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.forward-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.forward-chat-item:hover {
    background: rgba(108, 92, 231, 0.05);
}

.forward-chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.forward-chat-info {
    flex: 1;
}

.forward-chat-name {
    font-size: 15px;
    font-weight: 500;
    color: #333;
}

.loading,
.no-chats,
.error {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 14px;
}

.error {
    color: #ff6b6b;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .forward-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .forward-modal-header {
        padding: 16px;
    }
    
    .forward-modal-body {
        padding: 16px;
    }
    
    .file-context-menu {
        min-width: 180px;
        border-radius: 10px;
    }
    
    .context-menu-item {
        padding: 12px 18px;
    }
    
    .context-menu-item span {
        font-size: 14px;
    }
}

/* ========================================
   INVITE SECTION
   ======================================== */

.invite-link-container {
    display: flex;
    gap: 12px;
    align-items: center;
}

.invite-link-container input {
    flex: 1;
}

.share-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.share-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.share-btn:hover {
    background: rgba(108, 92, 231, 0.05);
    border-color: var(--primary-color);
}

.share-btn i {
    font-size: 18px;
}

.qr-code-container {
    display: flex;
    justify-content: center;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 8px;
}

#qr-canvas {
    border: 2px solid #ddd;
    border-radius: 8px;
}

@media (max-width: 768px) {
    .invite-link-container {
        flex-direction: column;
    }
    
    .invite-link-container button {
        width: 100%;
    }
    
    .share-buttons {
        flex-direction: column;
    }
    
    .share-btn {
        width: 100%;
    }
}

/* ========================================
   PINNED MESSAGES & MESSAGE CONTEXT MENU
   ======================================== */

/* Контейнер закрепленных сообщений */
.pinned-messages-container {
    background: rgba(108, 92, 231, 0.1);
    border-bottom: 1px solid rgba(108, 92, 231, 0.2);
    padding: 8px 16px;
    display: none;
}

.pinned-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
}

.pinned-message:last-child {
    margin-bottom: 0;
}

.pinned-message:hover {
    background: rgba(108, 92, 231, 0.05);
}

.pinned-message-icon {
    color: var(--primary-color);
    font-size: 16px;
}

.pinned-message-content {
    flex: 1;
    min-width: 0;
}

.pinned-message-text {
    font-size: 14px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pinned-message-close {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.pinned-message-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #666;
}

/* Подсветка сообщения */
.message.highlight {
    animation: messageHighlight 2s ease;
}

@keyframes messageHighlight {
    0%, 100% {
        background: transparent;
    }
    50% {
        background: rgba(108, 92, 231, 0.1);
    }
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .pinned-messages-container {
        padding: 8px 12px;
    }
    
    .pinned-message {
        padding: 6px;
    }
    
    .pinned-message-text {
        font-size: 13px;
    }
}

/* ========================================
   LOAD MORE MESSAGES
   ======================================== */

.load-more-messages {
    text-align: center;
    padding: 16px;
    margin: 8px 0;
}

.load-more-messages button {
    background: rgba(108, 92, 231, 0.1);
    border: 1px solid rgba(108, 92, 231, 0.3);
    color: var(--primary-color);
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.load-more-messages button:hover {
    background: rgba(108, 92, 231, 0.2);
    transform: translateY(-2px);
}

.load-more-messages button i {
    font-size: 12px;
}

/* Выделенные сообщения */
.message.selected {
    background: rgba(108, 92, 231, 0.15) !important;
    border-left: 3px solid var(--primary-color);
    padding-left: 9px;
}

.message.selected::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
    border-radius: 2px 0 0 2px;
}

/* Индикатор редактирования */
.edit-indicator {
    margin-bottom: 8px;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.edit-indicator button:hover {
    color: var(--text-primary) !important;
}

/* Метка "edited" (как в Telegram) */
.edited-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 4px;
    font-style: normal;
    opacity: 0.7;
}

/* Модальное окно пересылки */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Чат-элементы в модальном окне */
.modal-body .chat-item:hover {
    background: var(--bg-tertiary);
}

/* Модальное окно удаления сообщения */
.delete-message-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.delete-message-modal.active {
    opacity: 1;
}

.delete-message-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    cursor: pointer;
}

.delete-message-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.delete-message-modal.active .delete-message-content {
    transform: scale(1) translateY(0);
}

.delete-message-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 20px 0;
    text-align: center;
}

.delete-message-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.delete-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.delete-btn:active {
    transform: translateY(0);
}

.delete-btn.delete-for-everyone {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.delete-btn.delete-for-everyone:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
}

.delete-btn.delete-for-me {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

.delete-btn.delete-for-me:hover {
    background: linear-gradient(135deg, #e67e22, #d35400);
}

.delete-btn.cancel-delete {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.delete-btn.cancel-delete:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.delete-btn i {
    font-size: 1.1rem;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 16px;
    }
    
    .modal-body {
        padding: 16px;
    }
    
    .delete-message-content {
        padding: 20px;
    }
    
    .delete-btn {
        padding: 12px 16px;
        font-size: 0.95rem;
    }
}

/* Реакции на сообщения */
.reaction-picker {
    position: fixed;
    background: #2a2a3e;
    border: 2px solid var(--primary-color);
    border-radius: 16px;
    padding: 10px;
    display: flex;
    gap: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
    z-index: 99999;
    animation: reactionPickerPop 0.2s ease-out;
}

@keyframes reactionPickerPop {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.reaction-btn {
    background: rgba(108, 92, 231, 0.1);
    border: 1px solid transparent;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 10px;
    border-radius: 10px;
    transition: all 0.2s;
    line-height: 1;
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reaction-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(1.2);
}

.reaction-btn:active {
    transform: scale(0.95);
}

/* Контейнер реакций под сообщением */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    margin-bottom: 6px;
    min-height: 32px;
}

.message-reaction {
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border-color);
    border-radius: 16px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    min-width: 50px;
    justify-content: center;
}

.message-reaction:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.message-reaction.own-reaction {
    background: rgba(108, 92, 231, 0.3);
    border-color: var(--primary-color);
    border-width: 2px;
}

.message-reaction.own-reaction:hover {
    background: rgba(108, 92, 231, 0.4);
}

.reaction-emoji {
    font-size: 1.3rem;
    line-height: 1;
}

.reaction-count {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 600;
}

.message-reaction.own-reaction .reaction-count {
    color: var(--primary-color);
    font-weight: 700;
}

.message-reaction.own-reaction:hover {
    background: rgba(108, 92, 231, 0.3);
}

.reaction-emoji {
    font-size: 1rem;
    line-height: 1;
}

.reaction-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.message-reaction.own-reaction .reaction-count {
    color: var(--primary-color);
}

.reaction-pop {
    animation: reactionPop 0.3s ease-out;
}

@keyframes reactionPop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .reaction-picker {
        padding: 6px;
    }
    
    .reaction-btn {
        font-size: 1.3rem;
        padding: 6px;
    }
    
    .message-reaction {
        padding: 3px 6px;
    }
}

/* Кнопка реакции на сообщении */
.message-reaction-btn {
    position: absolute;
    top: -12px;
    right: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.message-reaction-btn i {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.message-reaction-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.message-reaction-btn:hover i {
    color: var(--primary-color);
}

.message-reaction-btn:active {
    transform: scale(0.95);
}

/* Показываем кнопку при наведении на сообщение (только на десктопе) */
@media (hover: hover) and (pointer: fine) {
    .message:hover .message-reaction-btn {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Для своих сообщений кнопка слева */
.message.own .message-reaction-btn {
    right: auto;
    left: 12px;
}

/* На мобильных скрываем кнопку реакции (используем контекстное меню) */
@media (max-width: 768px), (hover: none) {
    .message-reaction-btn {
        display: none;
    }
}

/* Кнопка меню вложений (три точки) */
.attach-menu-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    border-radius: 50%;
    border: none;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    flex-shrink: 0;
    position: relative;
}

.attach-menu-btn:hover {
    background-color: var(--bg-hover);
    color: var(--primary-color);
}

.attach-menu-btn.active {
    background-color: var(--primary-color);
    color: white;
}

/* Выпадающее меню вложений */
.attach-menu {
    position: absolute;
    bottom: 60px;
    left: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    min-width: 200px;
    animation: slideUp 0.2s ease-out;
}

.attach-menu.hidden {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Элементы меню */
.attach-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: none;
    background: none;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 0.9rem;
    text-align: left;
}

.attach-menu-item:hover {
    background: var(--bg-tertiary);
}

.attach-menu-item i {
    width: 20px;
    text-align: center;
    color: var(--text-secondary);
}

.attach-menu-item:hover i {
    color: var(--primary-color);
}

.attach-menu-item span {
    flex: 1;
}

/* Адаптация для мобильных */
@media (max-width: 479px) {
    .attach-menu {
        left: 8px;
        bottom: 55px;
        min-width: 180px;
    }
    
    .attach-menu-item {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
}

/* Галочка на выделенных сообщениях */
.message-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    z-index: 5;
    animation: checkboxPop 0.2s ease-out;
}

@keyframes checkboxPop {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

.message.own .message-checkbox {
    left: auto;
    right: 8px;
}

/* Панель выделения */
.selection-toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 12px 16px;
    display: none;
    align-items: center;
    gap: 16px;
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
}

.selection-toolbar.hidden {
    display: none !important;
}

.selection-toolbar .count {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
}

.selection-toolbar button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.selection-toolbar button:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.selection-toolbar #cancel-selection-btn {
    background: var(--danger);
    color: white;
}

.selection-toolbar #cancel-selection-btn:hover {
    background: #c0392b;
}

/* ========================================
   АДАПТАЦИЯ ДЛЯ ВСЕХ РАЗМЕРОВ ЭКРАНОВ
   ======================================== */

/* Маленькие ноутбуки (1024px - 1366px) */
@media (min-width: 1024px) and (max-width: 1366px) {
    .sidebar {
        width: 320px;
        min-width: 320px;
    }
    
    .message {
        max-width: 75%;
    }
    
    .chat-header {
        padding: 14px 18px;
    }
}

/* Стандартные мониторы (1367px - 1920px) */
@media (min-width: 1367px) and (max-width: 1920px) {
    .sidebar {
        width: 380px;
        min-width: 380px;
    }
    
    .message {
        max-width: 70%;
    }
}

/* Большие мониторы (1921px+) */
@media (min-width: 1921px) {
    .app-container {
        max-width: 2400px;
        margin: 0 auto;
    }
    
    .sidebar {
        width: 420px;
        min-width: 420px;
    }
    
    .message {
        max-width: 65%;
        font-size: 1rem;
    }
    
    .message-content {
        padding: 12px 16px;
    }
    
    .chat-header {
        padding: 16px 20px;
    }
}

/* Очень большие мониторы (2560px+) */
@media (min-width: 2560px) {
    .app-container {
        max-width: 3000px;
    }
    
    .sidebar {
        width: 480px;
        min-width: 480px;
    }
    
    .message {
        max-width: 60%;
        font-size: 1.05rem;
    }
    
    .chat-input {
        font-size: 1rem;
    }
}

/* Адаптация высоты для разных экранов */
@media (max-height: 768px) {
    .messages-container {
        max-height: calc(100vh - 180px);
    }
    
    .emoji-picker,
    .gif-picker {
        height: 350px;
    }
}

@media (min-height: 1080px) {
    .messages-container {
        max-height: calc(100vh - 160px);
    }
    
    .emoji-picker,
    .gif-picker {
        height: 500px;
    }
}

@media (min-height: 1440px) {
    .emoji-picker,
    .gif-picker {
        height: 600px;
    }
}

/* Адаптация для ультраширокоформатных мониторов (21:9) */
@media (min-aspect-ratio: 21/9) {
    .app-container {
        max-width: 2000px;
        margin: 0 auto;
    }
}

/* Адаптация для вертикальных мониторов */
@media (max-aspect-ratio: 3/4) {
    .sidebar {
        width: 100%;
        max-width: 400px;
    }
    
    .message {
        max-width: 85%;
    }
}

/* Масштабирование для высокого DPI (Retina и т.д.) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .message-content {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    .avatar img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Обеспечиваем минимальную ширину приложения */
body {
    min-width: 320px;
}

.app-container {
    min-width: 320px;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* Адаптация модальных окон для больших экранов */
@media (min-width: 1920px) {
    .modal-content {
        max-width: 600px;
    }
    
    .emoji-picker,
    .gif-picker {
        max-width: 450px;
    }
}

/* ===== ADDITIONAL RESPONSIVE ADAPTATIONS ===== */

/* Compact Mode for Small Screens */
@media (max-width: 1365px) {
    .chat-input {
        font-size: 0.85rem;
        padding: 8px 12px;
    }
    
    .send-btn, .voice-input-btn, .file-input-btn, .format-toggle-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        font-size: 0.85rem;
    }
    
    .message-input-container {
        padding: 8px 10px;
        gap: 6px;
    }
    
    .chat-item {
        padding: 10px 14px;
    }
    
    .avatar {
        width: 36px;
        height: 36px;
    }
}

/* Enhanced Readability for Large Screens */
@media (min-width: 2560px) {
    .chat-input {
        font-size: 1.05rem;
        padding: 12px 16px;
        min-height: 44px;
    }
    
    .send-btn, .voice-input-btn, .file-input-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 1.1rem;
    }
    
    .format-toggle-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
    }
    
    .chat-item {
        padding: 14px 18px;
    }
    
    .avatar {
        width: 48px;
        height: 48px;
    }
    
    .chat-name {
        font-size: 1.05rem;
    }
    
    .chat-preview {
        font-size: 0.95rem;
    }
}

/* Touch-Friendly Adjustments for Tablets */
@media (min-width: 768px) and (max-width: 1023px) and (pointer: coarse) {
    .send-btn, .voice-input-btn, .file-input-btn, .format-toggle-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
    }
    
    .chat-item {
        padding: 14px 16px;
    }
    
    .context-menu-item {
        padding: 14px 18px;
        min-height: 48px;
    }
}

/* Optimize for Dual/Triple Monitor Setups */
@media (min-width: 1920px) {
    .app-container {
        max-width: 2400px;
        margin: 0 auto;
    }
}

/* Landscape Mobile Phones */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar-header {
        padding: 8px 12px;
    }
    
    .chat-header {
        padding: 8px 12px;
    }
    
    .messages-container {
        padding: 12px;
    }
    
    .message-input-container {
        padding: 6px 10px;
    }
    
    .chat-input {
        height: 32px;
        min-height: 32px;
        padding: 6px 10px;
    }
}

/* Accessibility: Large Text Mode */
@media (prefers-contrast: high) {
    body {
        --border-color: #3a3a4a;
    }
    
    .message.own .message-content {
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    .message.other .message-content {
        border: 1px solid var(--border-color);
    }
}

/* Dark Mode Optimization for OLED Screens */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #000000;
        --bg-secondary: #0d0d0d;
        --bg-tertiary: #1a1a1a;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .chat-input-area,
    .chat-header,
    .back-btn {
        display: none !important;
    }
    
    .chat-area {
        width: 100% !important;
    }
    
    .messages-container {
        padding: 0;
    }
    
    .message {
        page-break-inside: avoid;
    }
}

/* ===== ZOOM & SCALE ADAPTATION ===== */

/* Адаптация для увеличенного масштаба браузера */
@media (min-resolution: 1.25dppx) and (max-resolution: 1.49dppx) {
    /* Масштаб 125% */
    body {
        font-size: 15px;
    }
    
    .app-container {
        max-width: 100%;
    }
    
    .sidebar {
        min-width: 280px;
        width: 280px;
    }
    
    .message {
        max-width: 75%;
    }
}

@media (min-resolution: 1.5dppx) and (max-resolution: 1.99dppx) {
    /* Масштаб 150% */
    body {
        font-size: 14px;
    }
    
    .sidebar {
        min-width: 260px;
        width: 260px;
    }
    
    .message {
        max-width: 80%;
    }
    
    .messages-container {
        padding: 16px;
    }
}

@media (min-resolution: 2dppx) {
    /* Масштаб 200%+ */
    body {
        font-size: 13px;
    }
    
    .sidebar {
        min-width: 240px;
        width: 240px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .messages-container {
        padding: 12px;
    }
    
    .chat-header, .sidebar-header {
        padding: 12px;
    }
}

/* Фиксация краев при любом масштабе */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
    position: relative;
}

.app-container {
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
}

.sidebar {
    overflow-x: hidden;
}

.chat-area {
    overflow-x: hidden;
    max-width: 100%;
}

.messages-container {
    overflow-x: hidden;
    max-width: 100%;
}

.message-content {
    max-width: 100%;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Адаптация для браузерного зума (Ctrl +/-) */
@supports (zoom: 1) {
    .app-container {
        width: 100%;
        max-width: 100vw;
    }
}

/* Предотвращение горизонтального скролла */
* {
    max-width: 100%;
}

img, video {
    max-width: 100%;
    height: auto;
}

/* Адаптация модальных окон при зуме */
.modal-content {
    max-width: 90vw;
    max-height: 90vh;
}

.media-viewer {
    max-width: 100vw;
    max-height: 100vh;
}

/* Адаптация контекстных меню */
.context-menu {
    max-width: 90vw;
}

/* Адаптация для Windows масштабирования дисплея */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .app-container {
        width: 100%;
    }
}

/* Адаптация для macOS Retina с масштабированием */
@media only screen and (-webkit-min-device-pixel-ratio: 2) and (min-resolution: 192dpi) {
    .app-container {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Компактный режим при большом зуме */
@media (max-width: 1200px) and (min-resolution: 1.5dppx) {
    .sidebar {
        min-width: 220px;
        width: 220px;
    }
    
    .chat-item {
        padding: 8px 12px;
    }
    
    .avatar {
        width: 32px;
        height: 32px;
    }
    
    .send-btn, .voice-input-btn, .file-input-btn, .format-toggle-btn {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
        font-size: 0.8rem;
    }
}

/* Экстра компактный режим при очень большом зуме */
@media (max-width: 900px) and (min-resolution: 2dppx) {
    .sidebar {
        position: absolute;
        width: 100%;
        min-width: 100%;
    }
    
    .chat-area {
        position: absolute;
        width: 100%;
        transform: translateX(100%);
    }
    
    .app-container.chat-active .sidebar {
        transform: translateX(-100%);
    }
    
    .app-container.chat-active .chat-area {
        transform: translateX(0);
    }
}

/* Фиксация для Electron при системном масштабировании */
.electron-app {
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.electron-app .app-container {
    width: 100%;
    height: 100%;
}

/* ===== MESSAGE SELECTION MODE (TELEGRAM STYLE) ===== */

/* Контейнер галочки */
.message-checkbox-container {
    position: absolute;
    left: -40px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: none; /* Скрываем по умолчанию */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
}

/* Показываем галочки в режиме выделения */
.messages-container.selection-mode .message-checkbox-container {
    display: flex; /* Показываем в режиме выделения */
    opacity: 1;
    left: 8px;
}

/* Галочка */
.message-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    transition: all 0.2s ease;
}

.message-checkbox i {
    font-size: 12px;
    color: white;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Галочка при наведении */
.message-checkbox-container:hover .message-checkbox {
    border-color: var(--primary-color);
    background: rgba(108, 92, 231, 0.1);
}

/* Выбранная галочка */
.message-checkbox.checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.message-checkbox.checked i {
    opacity: 1;
}

/* Сообщение в режиме выделения */
.messages-container.selection-mode .message {
    margin-left: 40px;
    transition: all 0.2s ease;
}

/* Выбранное сообщение */
.message.selected {
    background: rgba(108, 92, 231, 0.05);
    border-radius: 8px;
}

.message.selected .message-content {
    background: rgba(108, 92, 231, 0.1) !important;
}

/* Панель выделения */
.selection-toolbar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    transform: translateY(-100%);
    opacity: 0;
    transition: all 0.3s ease;
}

.selection-toolbar.visible {
    transform: translateY(0);
    opacity: 1;
}

/* Кнопки панели выделения */
.selection-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}

.selection-btn:hover {
    background: var(--bg-tertiary);
}

.selection-btn:active {
    transform: scale(0.95);
}

#cancel-selection-btn {
    color: var(--text-secondary);
}

#delete-selected-btn {
    color: var(--danger);
}

#delete-selected-btn:hover {
    background: rgba(214, 48, 49, 0.1);
}

/* Счетчик выбранных */
.selection-count {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* Действия с выбранными */
.selection-actions {
    display: flex;
    gap: 4px;
}

/* Модальное окно пересылки */
.forward-modal-content {
    max-width: 500px;
    max-height: 80vh;
}

.forward-modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.forward-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.forward-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.forward-chat-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.forward-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-tertiary);
}

.forward-chat-item:hover {
    background: rgba(108, 92, 231, 0.1);
    transform: translateX(4px);
}

.forward-chat-item:active {
    transform: scale(0.98);
}

.forward-chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.forward-chat-info {
    flex: 1;
    min-width: 0;
}

.forward-chat-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.forward-chat-item i {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Состояния загрузки */
.loading, .no-chats, .error {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.loading i {
    font-size: 24px;
    margin-bottom: 12px;
    display: block;
}

.error {
    color: var(--danger);
}

/* Адаптация для мобильных */
@media (max-width: 767px) {
    .messages-container.selection-mode .message {
        margin-left: 36px;
    }
    
    .message-checkbox-container {
        left: 4px;
        width: 28px;
        height: 28px;
    }
    
    .message-checkbox {
        width: 22px;
        height: 22px;
    }
    
    .selection-toolbar {
        height: 52px;
        padding: 0 12px;
    }
    
    .selection-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .selection-count {
        font-size: 0.9rem;
    }
    
    .forward-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .forward-modal-header,
    .forward-modal-body {
        padding: 16px;
    }
    
    .forward-chat-item {
        padding: 10px;
    }
    
    .forward-chat-avatar {
        width: 42px;
        height: 42px;
    }
}

/* Анимация появления галочек */
@keyframes checkboxAppear {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

.messages-container.selection-mode .message-checkbox-container {
    animation: checkboxAppear 0.2s ease;
}

/* ===== VOICE RECORDING UI ===== */

.voice-recording-ui {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: 24px;
    animation: slideInRecording 0.3s ease;
}

@keyframes slideInRecording {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.voice-cancel-btn,
.voice-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.voice-cancel-btn {
    background: var(--danger);
    color: white;
}

.voice-cancel-btn:hover {
    background: #b71c1c;
    transform: scale(1.1);
}

.voice-send-btn {
    background: var(--primary-color);
    color: white;
}

.voice-send-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.voice-recording-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.voice-recording-wave {
    display: flex;
    align-items: center;
    gap: 4px;
}

.wave-dot {
    width: 4px;
    height: 12px;
    background: var(--danger);
    border-radius: 2px;
    animation: waveAnimation 1s ease-in-out infinite;
}

.wave-dot:nth-child(1) {
    animation-delay: 0s;
}

.wave-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.wave-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes waveAnimation {
    0%, 100% {
        height: 12px;
    }
    50% {
        height: 24px;
    }
}

.voice-recording-timer {
    font-size: 1rem;
    font-weight: 600;
    color: var(--danger);
    font-variant-numeric: tabular-nums;
}

/* Мобильная адаптация */
@media (max-width: 767px) {
    .voice-cancel-btn,
    .voice-send-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .voice-recording-timer {
        font-size: 0.9rem;
    }
    
    .wave-dot {
        width: 3px;
        height: 10px;
    }
}

/* Emoji Picker Styles */
.emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 12px;
    width: 320px;
    height: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.emoji-picker.hidden {
    display: none;
}

.emoji-picker-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.emoji-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    margin-bottom: 8px;
}

.emoji-search:focus {
    border-color: var(--primary-color);
}

.emoji-categories {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 2px 0;
}

.emoji-category {
    background: none;
    border: none;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    flex-shrink: 0;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-category:hover {
    background: var(--bg-color);
}

.emoji-category.active {
    background: var(--primary-color);
    color: white;
}

.emoji-picker-content {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    align-content: start;
}

.emoji-item {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
    font-size: 1.2rem;
    transition: all 0.2s;
    user-select: none;
}

.emoji-item:hover {
    background: var(--bg-tertiary);
    transform: scale(1.1);
}

.my-emoji-item {
    border: 2px solid var(--primary-color);
    background: var(--bg-tertiary);
}

.my-emoji-item:hover {
    background: var(--primary-color);
    opacity: 0.8;
}

.empty-emoji-message {
    grid-column: 1 / -1;
}

/* GIF Picker Styles */
.gif-picker {
    position: absolute;
    bottom: 70px;
    left: 12px;
    width: 320px;
    height: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.gif-picker.hidden {
    display: none;
}

.gif-picker-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.gif-search {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}

.gif-search:focus {
    border-color: var(--primary-color);
}

.gif-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 1rem;
    transition: all 0.2s;
}

.gif-close-btn:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.gif-picker-content {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    align-content: start;
}

.gif-item {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-tertiary);
}

.gif-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.gif-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gif-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* 
Индикатор загрузки чатов */
.chats-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.chats-loading p {
    font-size: 14px;
    margin: 0;
}


/* Индикатор загрузки сообщений */
.messages-loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    transition: opacity 0.3s ease;
}

.messages-loading-content {
    background: var(--bg-secondary);
    padding: 24px 32px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    min-width: 250px;
}

.messages-loading-content .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.messages-loading-content p {
    margin: 0;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.loading-progress-bar {
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.loading-progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .messages-loading-content {
        padding: 20px 24px;
        min-width: 200px;
    }
    
    .messages-loading-content .loading-spinner {
        width: 32px;
        height: 32px;
    }
    
    .messages-loading-content p {
        font-size: 13px;
    }
}


/* Стили для кнопок в панели ввода */
.attach-btn,
.emoji-btn,
.gif-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.attach-btn:hover,
.emoji-btn:hover,
.gif-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary-color);
}

.attach-btn:active,
.emoji-btn:active,
.gif-btn:active {
    transform: scale(0.95);
}

/* Скрытый input для файлов */
.file-input {
    display: none;
}

/* Контейнер для input файлов */
.file-input-container {
    position: relative;
    display: inline-flex;
}

/* Textarea для сообщений */
.chat-input {
    flex: 1;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 20px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-family);
    resize: none;
    min-height: 38px;
    max-height: 200px;
    line-height: 1.4;
}

.chat-input:focus {
    outline: none;
    background: var(--bg-secondary);
}

.chat-input::placeholder {
    color: var(--text-secondary);
}

/* Кнопки голоса и отправки */
.voice-input-btn,
.send-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.send-btn {
    background: var(--primary-color);
    color: white;
}

.send-btn:hover {
    background: #5a4bc7;
    transform: scale(1.05);
}

.voice-input-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary-color);
}

.voice-input-btn:active,
.send-btn:active {
    transform: scale(0.95);
}

/* Панель ввода */
.message-input-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}


/* Кнопка "Показать еще" */
.load-more-messages {
    display: flex;
    justify-content: center;
    padding: 16px;
    margin: 8px 0;
}

.load-more-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font-family);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.load-more-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.load-more-btn:active {
    transform: translateY(0);
}

.load-more-btn i {
    font-size: 12px;
}


/* ============================================
   ПЛАВНЫЕ АНИМАЦИИ - МАКСИМАЛЬНАЯ ПЛАВНОСТЬ
   ============================================ */

/* Глобальные настройки плавности */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Плавные переходы для всех интерактивных элементов */
button,
a,
input,
textarea,
select,
.chat-item,
.message,
.emoji-item,
.gif-item,
.context-menu-item {
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Плавное появление сообщений */
.message {
    animation: messageAppear 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Плавное появление изображений */
.message-image,
.message-gif {
    animation: imageAppear 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
}

@keyframes imageAppear {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Плавный hover для кнопок */
button:hover,
.attach-btn:hover,
.emoji-btn:hover,
.gif-btn:hover {
    transform: scale(1.05);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

button:active,
.attach-btn:active,
.emoji-btn:active,
.gif-btn:active {
    transform: scale(0.95);
    transition: transform 0.1s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Плавное появление чатов */
.chat-item {
    animation: chatAppear 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    animation-fill-mode: both;
}

@keyframes chatAppear {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Задержка для каждого чата */
.chat-item:nth-child(1) { animation-delay: 0.05s; }
.chat-item:nth-child(2) { animation-delay: 0.1s; }
.chat-item:nth-child(3) { animation-delay: 0.15s; }
.chat-item:nth-child(4) { animation-delay: 0.2s; }
.chat-item:nth-child(5) { animation-delay: 0.25s; }

/* Плавный hover для чатов */
.chat-item:hover {
    transform: translateX(5px);
    background: var(--bg-tertiary);
}

/* Плавное появление модальных окон */
.modal,
.file-context-menu,
.emoji-picker,
.gif-picker {
    animation: modalAppear 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Плавное исчезновение */
.fade-out {
    animation: fadeOut 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Плавный спиннер */
.loading-spinner,
.image-spinner,
.video-spinner,
.media-spinner {
    animation: smoothSpin 1s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
}

@keyframes smoothSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Плавное появление эмодзи */
.emoji-item {
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.emoji-item:hover {
    transform: scale(1.3);
    background: var(--bg-tertiary);
}

/* Плавное появление уведомлений */
.notification {
    animation: notificationSlide 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
}

@keyframes notificationSlide {
    from {
        opacity: 0;
        transform: translateY(-20px) translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0) translateX(0);
    }
}

/* Плавный progress bar */
.loading-progress-fill {
    transition: width 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Плавное появление textarea */
.chat-input {
    transition: height 0.2s cubic-bezier(0.4, 0.0, 0.2, 1),
                background 0.3s ease;
}

/* Плавное появление галочек выделения */
.message-checkbox-container {
    animation: checkboxAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes checkboxAppear {
    from {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* Плавное появление реакций */
.message-reactions {
    animation: reactionsAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes reactionsAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(5px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Плавный скролл */
html {
    scroll-behavior: smooth;
}

.messages-container {
    scroll-behavior: smooth;
}

/* Плавное появление индикатора загрузки */
.messages-loading-indicator,
.chats-loading {
    animation: loadingAppear 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
}

@keyframes loadingAppear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Плавное появление кнопки отправки */
.send-btn {
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.send-btn:hover {
    transform: scale(1.1) rotate(15deg);
}

/* Плавное появление голосового индикатора */
.voice-recording {
    animation: pulse 1.5s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

/* Улучшенная анимация для медиа */
.image-message,
.video-message,
.gif-message {
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.image-message:hover,
.video-message:hover,
.gif-message:hover {
    transform: scale(1.02);
}

/* Плавное появление контекстного меню */
.context-menu-item {
    animation: menuItemAppear 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    animation-fill-mode: both;
}

.context-menu-item:nth-child(1) { animation-delay: 0.05s; }
.context-menu-item:nth-child(2) { animation-delay: 0.1s; }
.context-menu-item:nth-child(3) { animation-delay: 0.15s; }
.context-menu-item:nth-child(4) { animation-delay: 0.2s; }
.context-menu-item:nth-child(5) { animation-delay: 0.25s; }

@keyframes menuItemAppear {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Плавный hover для контекстного меню */
.context-menu-item:hover {
    transform: translateX(5px);
    background: var(--bg-tertiary);
}

/* Reduce motion для пользователей с настройками доступности */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
