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

        :root {
            --bg-primary: #667eea;
            --bg-secondary: #764ba2;
            --text-primary: #ffffff;
            --text-secondary: rgba(255, 255, 255, 0.7);
            --bg-light: rgba(255, 255, 255, 0.15);
            --bg-lighter: rgba(255, 255, 255, 0.1);
            --border-color: rgba(255, 255, 255, 0.2);
            --message-sent: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            --message-received: rgba(255, 255, 255, 0.2);
        }

        body.dark-theme {
            --bg-primary: #1a1a2e;
            --bg-secondary: #16213e;
            --text-primary: #ffffff;
            --text-secondary: rgba(255, 255, 255, 0.6);
            --bg-light: rgba(255, 255, 255, 0.08);
            --bg-lighter: rgba(255, 255, 255, 0.05);
            --border-color: rgba(255, 255, 255, 0.1);
            --message-sent: #0f3460;
            --message-received: rgba(255, 255, 255, 0.1);
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
            height: 100vh;
            overflow: hidden;
            transition: background 0.3s ease;
        }

        .container {
            display: flex;
            height: 100vh;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            margin: 10px;
            box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
        }

        /* ===== САЙДБАР ===== */
        .sidebar {
            width: 300px;
            min-width: 250px;
            background: var(--bg-light);
            backdrop-filter: blur(15px);
            border-radius: 20px 0 0 20px;
            border-right: 1px solid var(--border-color);
            display: flex;
            flex-direction: column;
        }

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

        .sidebar-header h2 {
            color: var(--text-primary);
            font-size: 24px;
        }

        .settings-btn {
            width: 36px;
            height: 36px;
            border: none;
            border-radius: 50%;
            background: var(--bg-lighter);
            color: var(--text-primary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            transition: all 0.3s ease;
        }

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

        .search-box {
            width: 100%;
            padding: 12px 15px;
            border: none;
            border-radius: 25px;
            background: var(--bg-lighter);
            color: var(--text-primary);
            font-size: 14px;
            outline: none;
            margin-top: 10px;
        }

        .search-box::placeholder {
            color: var(--text-secondary);
        }

        .chat-list {
            flex: 1;
            overflow-y: auto;
            padding: 10px 0;
        }

        .chat-item {
            display: flex;
            align-items: center;
            padding: 15px 20px;
            cursor: pointer;
            transition: all 0.3s ease;
            border-left: 3px solid transparent;
            position: relative;
        }

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

        .chat-item.active {
            background: var(--bg-light);
            border-left-color: #4CAF50;
        }

        .chat-item.pinned {
            background: var(--bg-lighter);
        }

        .chat-avatar {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            margin-right: 15px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            color: white;
            font-size: 18px;
            flex-shrink: 0;
        }

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

        .chat-name {
            color: var(--text-primary);
            font-weight: 600;
            margin-bottom: 5px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .pin-icon {
            font-size: 12px;
            opacity: 0.7;
        }

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

        .chat-badges {
            display: flex;
            gap: 5px;
            margin-left: 10px;
            flex-shrink: 0;
        }

        .badge {
            background: #ff6b6b;
            color: white;
            border-radius: 50%;
            width: 20px;
            height: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 10px;
            font-weight: bold;
        }

        .pin-btn {
            position: absolute;
            right: 10px;
            top: 50%;
            transform: translateY(-50%);
            background: none;
            border: none;
            color: var(--text-secondary);
            cursor: pointer;
            font-size: 16px;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .chat-item:hover .pin-btn {
            opacity: 1;
        }

        /* ===== ОСНОВНАЯ ОБЛАСТЬ ===== */
        .main-content {
            flex: 1;
            display: flex;
            position: relative;
        }

        .resizer {
            width: 4px;
            background: var(--border-color);
            cursor: col-resize;
            transition: background 0.3s ease;
            position: relative;
        }

        .resizer:hover {
            background: rgba(255, 255, 255, 0.3);
        }

        .resizer::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 2px;
            height: 30px;
            background: rgba(255, 255, 255, 0.5);
            border-radius: 1px;
        }

        /* ===== ЛЕВЫЙ ЧАТ (АДМИНИСТРАТОРЫ) ===== */
        .left-chat {
            flex: 1;
            min-width: 300px;
            background: var(--bg-lighter);
            display: flex;
            flex-direction: column;
        }

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

        .chat-header-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            color: white;
            cursor: pointer;
            transition: transform 0.3s ease;
            flex-shrink: 0;
        }

        .chat-header-avatar:hover {
            transform: scale(1.1);
        }

        .chat-header-avatar.back-btn {
            background: var(--bg-lighter);
            font-size: 20px;
        }

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

        .chat-header-info h3 {
            color: var(--text-primary);
            margin-bottom: 3px;
        }

        .chat-header-info p {
            color: var(--text-secondary);
            font-size: 12px;
        }

        .admin-avatars {
            display: flex;
            gap: 10px;
            overflow-x: auto;
            padding-bottom: 5px;
        }

        .admin-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            color: white;
            cursor: pointer;
            transition: all 0.3s ease;
            flex-shrink: 0;
            position: relative;
        }

        .admin-avatar:hover {
            transform: scale(1.15);
        }

        .admin-avatar .unread-badge {
            position: absolute;
            top: -5px;
            right: -5px;
            background: #ff6b6b;
            color: white;
            border-radius: 50%;
            width: 18px;
            height: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 10px;
            font-weight: bold;
        }

        /* ===== СРЕДНИЙ ЧАТ (ИИ) ===== */
        .middle-chat {
            flex: 1;
            min-width: 300px;
            background: var(--bg-lighter);
            display: flex;
            flex-direction: column;
        }

        /* ===== ПРАВЫЙ ЧАТ ===== */
        .right-chat {
            flex: 1;
            min-width: 300px;
            background: var(--bg-lighter);
            display: flex;
            flex-direction: column;
            border-radius: 0 20px 20px 0;
        }

        /* ===== СООБЩЕНИЯ ===== */
        .chat-messages {
            flex: 1;
            padding: 20px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .message {
            max-width: 70%;
            padding: 12px 16px;
            border-radius: 18px;
            word-wrap: break-word;
            position: relative;
            transition: all 0.3s ease;
            display: flex;
            gap: 10px;
            align-items: flex-end;
        }

        .message.sent {
            align-self: flex-end;
            background: var(--message-sent);
            color: var(--text-primary);
            flex-direction: row-reverse;
        }

        .message.received {
            align-self: flex-start;
            background: var(--message-received);
            color: var(--text-primary);
        }

        .message-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            color: white;
            font-size: 12px;
            flex-shrink: 0;
        }

        .message-content {
            flex: 1;
        }

        .message:hover .message-actions {
            opacity: 1;
            visibility: visible;
        }

        .message-actions {
            position: absolute;
            top: -10px;
            right: -10px;
            display: flex;
            gap: 5px;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s ease;
        }

        .message.received .message-actions {
            left: -10px;
            right: auto;
        }

        .action-btn {
            width: 24px;
            height: 24px;
            border: none;
            border-radius: 50%;
            background: rgba(0, 0, 0, 0.7);
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            transition: all 0.3s ease;
        }

        .action-btn:hover {
            background: rgba(0, 0, 0, 0.9);
            transform: scale(1.1);
        }

        .forward-menu {
            position: absolute;
            background: rgba(0, 0, 0, 0.95);
            border-radius: 8px;
            min-width: 200px;
            z-index: 1000;
            display: none;
            flex-direction: column;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        .forward-menu.show {
            display: flex;
        }

        .forward-item {
            padding: 10px 15px;
            color: white;
            cursor: pointer;
            transition: background 0.2s ease;
            border: none;
            background: none;
            text-align: left;
            font-size: 14px;
        }

        .forward-item:hover {
            background: rgba(255, 255, 255, 0.1);
        }

        .forward-item.divider {
            border-top: 1px solid rgba(255, 255, 255, 0.2);
            padding: 5px 15px;
            cursor: default;
            font-size: 11px;
            color: rgba(255, 255, 255, 0.5);
        }

        /* ===== INPUT ===== */
        .chat-input {
            padding: 20px;
            border-top: 1px solid var(--border-color);
        }

        .input-container {
            display: flex;
            align-items: center;
            background: var(--bg-light);
            border-radius: 25px;
            padding: 5px;
            gap: 10px;
        }

        .input-icon {
            width: 32px;
            height: 32px;
            border: none;
            background: transparent;
            color: var(--text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: all 0.3s ease;
            font-size: 16px;
        }

        .input-icon:hover {
            background: var(--bg-lighter);
            color: var(--text-primary);
        }

        .message-input {
            flex: 1;
            border: none;
            background: transparent;
            padding: 12px 15px;
            color: var(--text-primary);
            outline: none;
            font-size: 14px;
        }

        .message-input::placeholder {
            color: var(--text-secondary);
        }

        .send-button {
            width: 40px;
            height: 40px;
            border: none;
            border-radius: 50%;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: transform 0.2s ease;
            font-size: 16px;
        }

        .send-button:hover {
            transform: scale(1.1);
        }

        .generate-btn {
            width: 40px;
            height: 40px;
            border: none;
            border-radius: 50%;
            background: #4CAF50;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: transform 0.2s ease;
            font-size: 16px;
        }

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

        /* ===== СКРОЛЛБАР ===== */
        ::-webkit-scrollbar {
            width: 6px;
        }

        ::-webkit-scrollbar-track {
            background: var(--bg-lighter);
        }

        ::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.3);
            border-radius: 3px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.5);
        }

        /* ===== МОДАЛЬНЫЕ ОКНА ===== */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 2000;
            align-items: center;
            justify-content: center;
        }

        .modal.show {
            display: flex;
        }

        .modal-content {
            background: var(--bg-primary);
            padding: 30px;
            border-radius: 15px;
            min-width: 400px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
        }

        .modal-content h3 {
            color: var(--text-primary);
            margin-bottom: 20px;
        }

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

        .settings-group label {
            color: var(--text-primary);
            display: block;
            margin-bottom: 10px;
            font-weight: 600;
        }

        .theme-toggle {
            display: flex;
            gap: 10px;
        }

        .theme-btn {
            flex: 1;
            padding: 10px;
            border: 2px solid var(--border-color);
            background: transparent;
            color: var(--text-primary);
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .theme-btn.active {
            background: #4CAF50;
            border-color: #4CAF50;
        }

        .modal-buttons {
            display: flex;
            gap: 10px;
            justify-content: flex-end;
            margin-top: 20px;
        }

        .modal-btn {
            padding: 10px 20px;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .modal-btn.close {
            background: #f44336;
            color: white;
        }

        .modal-btn.close:hover {
            background: #d32f2f;
        }

        /* ===== DRAG & DROP ===== */
        .message.dragging {
            opacity: 0.5;
        }

        .chat-messages.drag-over {
            background: rgba(76, 175, 80, 0.1);
        }

        /* ===== АДАПТИВНОСТЬ ===== */
        @media (max-width: 1200px) {
            .middle-chat {
                min-width: 250px;
            }
        }

        @media (max-width: 768px) {
            .container {
                margin: 5px;
                border-radius: 15px;
            }
            
            .sidebar {
                width: 250px;
            }
            
            .right-chat {
                display: none;
            }
            
            .resizer:last-of-type {
                display: none;
            }

            .message {
                max-width: 85%;
            }
        }