* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; height: 100vh; overflow: hidden; background: #1a1a2e; color: #eee; }
#app { display: flex; height: 100vh; }

/* ── Column 1: Account Avatars with Names ── */
.col-accounts { width: 260px; background: #0f1a30; display: flex; flex-direction: column; border-right: 1px solid #0f3460; flex-shrink: 0; }
.col-accounts-header { padding: 12px 0; text-align: center; font-size: 11px; color: #e94560; font-weight: 700; letter-spacing: 1px; border-bottom: 1px solid #0f3460; flex-shrink: 0; cursor: default; }
.col-accounts-body { flex: 1; overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; gap: 2px; }
.col-accounts-footer { padding: 8px; border-top: 1px solid #0f3460; display: flex; flex-direction: column; align-items: center; gap: 4px; flex-shrink: 0; }
.col-accounts-footer .footer-actions { display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; }
.acc-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; transition: background 0.15s; border-left: 3px solid transparent; }
.acc-item:hover { background: rgba(255,255,255,0.04); }
.acc-item.active { background: rgba(233,69,96,0.12); border-left-color: #e94560; }
.acc-item .acc-avatar { width: 40px; height: 40px; border-radius: 50%; position: relative; flex-shrink: 0; }
.acc-item .acc-avatar .avatar-img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #16213e; display: block; }
.acc-item .acc-avatar .avatar-init { width: 40px; height: 40px; border-radius: 50%; background: #16213e; display: flex; align-items: center; justify-content: center; font-size: 15px; color: #888; }
.acc-item .acc-avatar .online-dot { width: 10px; height: 10px; border-radius: 50%; background: #4ade80; border: 2px solid #0f1a30; position: absolute; bottom: -1px; right: -1px; }
.acc-item .acc-avatar .offline-dot { width: 10px; height: 10px; border-radius: 50%; background: #555; border: 2px solid #0f1a30; position: absolute; bottom: -1px; right: -1px; }
.acc-item .acc-name { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #ccc; min-width: 0; }
.acc-item .acc-gear { width: 24px; height: 24px; border-radius: 50%; background: transparent; color: #555; font-size: 13px; border: none; cursor: pointer; display: none; align-items: center; justify-content: center; flex-shrink: 0; }
.acc-item:hover .acc-gear { display: inline-flex; }
.acc-item .acc-gear:hover { color: #e94560; background: rgba(233,69,96,0.15); }
.acc-item.dragging { opacity: 0.3; }
.acc-item.drag-over { background: rgba(233,69,96,0.2); }
.acc-action-btn { width: 36px; height: 36px; border: none; border-radius: 50%; background: transparent; color: #888; font-size: 18px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all 0.15s; flex-shrink: 0; }
.acc-action-btn:hover { background: rgba(233,69,96,0.15); color: #e94560; }
.acc-action-btn.add-btn { border: 2px dashed #e94560; color: #e94560; font-size: 20px; }
.acc-action-btn.add-btn:hover { background: #e94560; color: #fff; }

/* ── Column 2: Chat List (320px) ── */
.col-chats { width: 320px; background: #16213e; display: flex; flex-direction: column; border-right: 1px solid #0f3460; flex-shrink: 0; }
.chats-nav { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid #0f3460; flex-shrink: 0; }
.chats-nav button { flex: 1; padding: 6px 12px; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; background: transparent; color: #888; transition: all 0.15s; }
.chats-nav button.active { background: #e94560; color: #fff; }
.chats-nav button:hover:not(.active) { background: #1a1a3e; }
.chats-search { padding: 10px 12px; border-bottom: 1px solid #0f3460; flex-shrink: 0; }
.chats-search input { width: 100%; padding: 8px 12px; border: 1px solid #0f3460; border-radius: 8px; background: #1a1a2e; color: #eee; font-size: 13px; outline: none; }
.chats-search input:focus { border-color: #e94560; }
.chats-search input::placeholder { color: #555; }
.chats-list { flex: 1; overflow-y: auto; }
.chat-item-2 { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #0f3460; display: flex; align-items: center; gap: 12px; transition: background 0.1s; height: 64px; }
.chat-item-2:hover { background: #1a1a3e; }
.chat-item-2.active { background: #0f3460; }
.chat-item-2 .avatar { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; position: relative; }
.chat-item-2 .avatar img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: #0f3460; display: block; }
.chat-item-2 .avatar .avatar-init { width: 44px; height: 44px; border-radius: 50%; background: #0f3460; display: flex; align-items: center; justify-content: center; font-size: 16px; color: #888; }
.chat-item-2 .info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.chat-item-2 .top-row { display: flex; justify-content: space-between; align-items: center; }
.chat-item-2 .name { font-size: 14px; font-weight: 500; color: #eee; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.chat-item-2 .time { font-size: 11px; color: #666; flex-shrink: 0; }
.chat-item-2 .top-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; margin-left: 8px; }
.chat-item-2 .pin-btn { cursor: pointer; font-size: 12px; opacity: 0; transition: opacity 0.2s; user-select: none; line-height: 1; }
.chat-item-2:hover .pin-btn { opacity: 0.4; }
.chat-item-2 .pin-btn:hover { opacity: 1; }
.chat-item-2 .pin-btn.pinned { opacity: 0.7; }
.chat-item-2 .bottom-row { display: flex; justify-content: space-between; align-items: center; margin-top: 1px; }
.chat-item-2 .preview { font-size: 12px; color: #888; flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; overflow: hidden; }
.chat-item-2 .preview .preview-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-2 .badge-area { flex-shrink: 0; margin-left: 8px; display: flex; align-items: center; }
.chat-item-2 .unread-badge { background: #25D366; color: #fff; font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; line-height: 1; }
.chat-item-2 .pin-icon { font-size: 13px; opacity: 0.5; margin-right: 2px; }

/* ── Column 3: Chat Panel (flex-1) ── */
.col-chat { flex: 1; display: flex; flex-direction: column; background: #1a1a2e; min-width: 0; position: relative; }
.col-chat .empty-state { flex: 1; display: flex; align-items: center; justify-content: center; color: #555; font-size: 15px; flex-direction: column; gap: 8px; }
.col-chat .empty-state .empty-icon { font-size: 48px; opacity: 0.3; }

/* Chat Header */
#chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-header { padding: 12px 20px; background: #16213e; border-bottom: 1px solid #0f3460; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.chat-header-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #0f3460; display: flex; align-items: center; justify-content: center; font-size: 16px; color: #888; flex-shrink: 0; }
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-size: 15px; font-weight: 600; }
.chat-header-status { font-size: 11px; color: #888; }

/* Chat Messages - Realistic Messaging UI */
.chat-messages { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; }
.chat-messages .msg-wrap { display: flex; flex-direction: column; margin-bottom: 2px; }
.chat-messages .msg-wrap.group-start { margin-top: 8px; }
.chat-messages .msg-wrap.group-end { margin-bottom: 8px; }
.chat-messages .msg { max-width: 82%; padding: 6px 12px 2px; border-radius: 8px; font-size: 14px; line-height: 1.45; word-wrap: break-word; position: relative; }
.chat-messages .msg.outgoing { align-self: flex-end; background: linear-gradient(135deg, #056162 0%, #075e54 100%); border-top-right-radius: 2px; }
.chat-messages .msg.incoming { align-self: flex-start; background: #1f2c3e; border-top-left-radius: 2px; }
.chat-messages .msg.outgoing.tail { border-top-right-radius: 8px; }
.chat-messages .msg.incoming.tail { border-top-left-radius: 8px; }
.chat-messages .msg .sender { font-size: 12px; color: #e94560; font-weight: 600; margin-bottom: 1px; }
.chat-messages .msg .msg-text { margin-bottom: 2px; white-space: pre-wrap; }
.chat-messages .msg .msg-footer { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.chat-messages .msg .time { font-size: 10px; color: rgba(255,255,255,0.45); }
.chat-messages .msg.outgoing .time { color: rgba(255,255,255,0.6); }
.chat-messages .msg .read-receipt { font-size: 11px; color: #888; }
.chat-messages .msg.outgoing .read-receipt.read { color: #53bdeb; }
.chat-messages .msg .translated-tag { font-size: 10px; color: #e94560; font-style: italic; }
.chat-messages .typing-indicator { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.chat-messages .typing-indicator .dot { width: 6px; height: 6px; border-radius: 50%; background: #888; animation: typingBounce 1.4s infinite ease-in-out; }
.chat-messages .typing-indicator .dot:nth-child(1) { animation-delay: 0s; }
.chat-messages .typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.chat-messages .typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }
.chat-messages .typing-indicator .typing-text { font-size: 11px; color: #888; margin-left: 4px; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }
.chat-messages .msg .media-img { max-width: 240px; max-height: 240px; border-radius: 6px; display: block; margin: 2px 0 4px; cursor: pointer; }
.chat-messages .msg .sender-avatar { display: inline-flex; align-items: center; vertical-align: middle; margin-right: 4px; }
.chat-messages .msg .sender-avatar img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; background: #0f3460; }
.chat-messages .msg .sender-avatar .fallback { width: 20px; height: 20px; border-radius: 50%; background: #0f3460; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; color: #888; }
.chat-messages .date-separator { text-align: center; font-size: 11px; color: rgba(255,255,255,0.4); margin: 12px 0; position: relative; }
.chat-messages .date-separator span { background: #1a1a2e; padding: 0 12px; position: relative; z-index: 1; }
.chat-messages .date-separator::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(255,255,255,0.08); }

/* Chat Input */
.chat-input { display: flex; gap: 6px; padding: 10px 16px; background: #16213e; border-top: 1px solid #0f3460; align-items: flex-end; flex-shrink: 0; }
.chat-input textarea { flex: 1; padding: 10px; border: 1px solid #0f3460; border-radius: 8px; resize: none; background: #1a1a2e; color: #eee; font-size: 14px; outline: none; max-height: 80px; font-family: inherit; }
.chat-input textarea:focus { border-color: #e94560; }
.chat-input .action-btn { background: transparent; border: 1px solid #0f3460; border-radius: 8px; color: #888; font-size: 18px; cursor: pointer; padding: 6px 10px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; transition: all 0.15s; flex-shrink: 0; }
.chat-input .action-btn:hover { border-color: #e94560; color: #e94560; }
.chat-input .send-btn { padding: 8px 16px; background: #e94560; color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; white-space: nowrap; flex-shrink: 0; }
.chat-input .send-btn:hover { background: #d63850; }
.chat-input #attach-btn, .chat-input #emoji-btn { background: transparent; border: 1px solid #0f3460; font-size: 18px; line-height: 1; padding: 6px 10px; }

/* Emoji picker */
#emoji-picker { display: none; position: absolute; bottom: 72px; right: 16px; background: #16213e; border: 1px solid #0f3460; border-radius: 10px; padding: 8px; width: 320px; max-height: 200px; overflow-y: auto; z-index: 50; flex-wrap: wrap; gap: 2px; }
#emoji-picker.show { display: flex; }
#emoji-picker span { cursor: pointer; font-size: 22px; padding: 4px; border-radius: 4px; width: 36px; text-align: center; }
#emoji-picker span:hover { background: #0f3460; }

/* Bulk view */
#bulk-view { padding: 24px; overflow-y: auto; height: 100%; }
#bulk-view h2 { margin-bottom: 16px; color: #e94560; font-size: 16px; }
.bulk-form { display: flex; flex-direction: column; gap: 10px; max-width: 600px; }
.bulk-form label { font-size: 13px; color: #aaa; }
.bulk-form input, .bulk-form textarea { padding: 10px; border: 1px solid #0f3460; border-radius: 8px; background: #16213e; color: #eee; font-size: 14px; }
.bulk-form input:focus, .bulk-form textarea:focus { outline: none; border-color: #e94560; }
.bulk-form button { padding: 10px 24px; background: #e94560; color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: 15px; align-self: flex-start; }
.bulk-form button:hover { background: #d63850; }
#bulk-account-select { display: flex; flex-wrap: wrap; gap: 8px; }
#bulk-account-select label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; color: #ddd; background: #16213e; padding: 6px 12px; border-radius: 8px; border: 1px solid #0f3460; }
#bulk-account-select input[type="checkbox"] { accent-color: #e94560; }
#bulk-result { margin-top: 12px; padding: 12px; background: #16213e; border-radius: 8px; white-space: pre-wrap; font-size: 13px; max-height: 300px; overflow-y: auto; }

/* Modal */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-content { background: #16213e; padding: 24px; border-radius: 12px; width: 420px; max-width: 90%; display: flex; flex-direction: column; gap: 10px; }
.modal-content h2 { margin-bottom: 8px; color: #e94560; }
.modal-content label { font-size: 13px; color: #aaa; }
.modal-content input, .modal-content textarea, .modal-content select { padding: 10px; border: 1px solid #0f3460; border-radius: 8px; background: #1a1a2e; color: #eee; font-size: 14px; }
.modal-content button { padding: 10px; background: #e94560; color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: 15px; margin-top: 8px; }
.modal-content button:hover { background: #d63850; }
.close { float: right; font-size: 24px; cursor: pointer; color: #888; }
.close:hover { color: #e94560; }

/* Toast notifications */
.toast { position: fixed; top: 16px; right: 16px; background: #16213e; border: 1px solid #e94560; border-radius: 10px; padding: 12px 18px; max-width: 320px; z-index: 200; box-shadow: 0 4px 20px rgba(0,0,0,0.5); animation: slideIn 0.3s ease; cursor: pointer; }
.toast strong { color: #e94560; font-size: 14px; }
.toast span { color: #ccc; font-size: 13px; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Platform badges */
.plat-badge { display: inline; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* Settings panel (slide-in) */
#settings-panel { position: fixed; top: 0; right: 0; width: 320px; height: 100vh; background: #16213e; border-left: 1px solid #0f3460; display: flex; flex-direction: column; overflow-y: auto; z-index: 90; box-shadow: -4px 0 20px rgba(0,0,0,0.4); animation: slideInRight 0.2s ease; }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
.settings-panel-header { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid #0f3460; flex-shrink: 0; }
.settings-panel-header h3 { color: #e94560; font-size: 16px; }
.settings-panel-header .close-btn { background: none; border: none; color: #888; font-size: 22px; cursor: pointer; }
.settings-panel-header .close-btn:hover { color: #e94560; }
.settings-section { border-bottom: 1px solid #0f3460; display: flex; flex-direction: column; width: 100%; }
.settings-section-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; cursor: pointer; color: #e94560; font-size: 14px; font-weight: 600; user-select: none; flex-shrink: 0; }
.settings-section-header:hover { background: rgba(233,69,96,0.08); }
.collapse-icon { font-size: 10px; color: #888; transition: transform 0.2s; }
.collapse-icon.collapsed { transform: rotate(-90deg); }
.settings-section-body { padding: 0 16px 16px; display: flex; flex-direction: column; width: 100%; }
.settings-section-body.collapsed { display: none; }
#settings-account-details { display: flex; flex-direction: column; width: 100%; }
#settings-account-details .detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #0f3460; font-size: 13px; }
#settings-account-details .detail-row .label { color: #888; }
#settings-account-details .detail-row .value { color: #eee; }
.setting-row { margin-bottom: 16px; display: flex; flex-direction: column; width: 100%; }
.setting-row label { font-size: 13px; color: #ddd; display: block; margin-bottom: 4px; }
.setting-row select { width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 6px; background: #1a1a2e; color: #eee; font-size: 13px; cursor: pointer; }
.setting-row select:focus { outline: none; border-color: #e94560; }
.setting-hint { font-size: 11px; color: #888; margin-top: 4px; }

/* Auto-reply */
.toggle-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: #ddd; }
.toggle-label input[type="checkbox"] { accent-color: #e94560; width: 18px; height: 18px; cursor: pointer; }
#ar-reply-text { width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 6px; background: #1a1a2e; color: #eee; font-size: 13px; resize: vertical; font-family: inherit; }
#ar-reply-text:focus { outline: none; border-color: #e94560; }
#ar-keywords { width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 6px; background: #1a1a2e; color: #eee; font-size: 13px; }
#ar-keywords:focus { outline: none; border-color: #e94560; }
#ar-cooldown { width: 100%; padding: 8px; border: 1px solid #0f3460; border-radius: 6px; background: #1a1a2e; color: #eee; font-size: 13px; }
#ar-cooldown:focus { outline: none; border-color: #e94560; }
.btn-connect { padding: 8px 20px; background: #e94560; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn-connect:hover { background: #d63850; }
.btn-connect:disabled { opacity: 0.5; cursor: not-allowed; }

/* Chat avatars */
.chat-messages .msg .sender-avatar img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; background: #0f3460; }
.chat-messages .msg .sender-avatar .fallback { width: 20px; height: 20px; border-radius: 50%; background: #0f3460; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; color: #888; }

/* Old classes kept for backward compat */
.chat-item-title { font-size: 14px; }
.chat-item-last { font-size: 12px; color: #888; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.translate-indicator { font-size: 11px; color: #e94560; margin-left: 8px; }

/* Groups view */
#groups-view { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
#groups-list-view, #group-detail-view { flex: 1; display: flex; flex-direction: column; }
.group-item:hover { border-color: #2AABEE !important; }
#group-accounts-list label { font-size: 13px; display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid #222; }
#group-accounts-list label:last-child { border-bottom: none; }
#create-group-account-select label:hover, #add-to-group-account-select label:hover { background: rgba(42,171,238,0.05); }
#create-group-account-select input[type="checkbox"], #add-to-group-account-select input[type="checkbox"] { accent-color: #2AABEE; }

/* Filter view */
#filter-view { padding: 24px; overflow-y: auto; height: 100%; }
#filter-view h2 { margin-bottom: 16px; color: #e94560; font-size: 16px; }
#filter-view .bulk-form { max-width: 600px; }
#filter-results table { width: 100%; border-collapse: collapse; font-size: 12px; }
#filter-results th { background: #0f3460; padding: 6px; text-align: left; position: sticky; top: 0; }
#filter-results td { padding: 4px 6px; border-bottom: 1px solid #0f3460; }
#filter-results tr:hover { background: rgba(255,255,255,0.03); }
