/*
 * Dracula theme — mxjs-lite chat
 *
 * Palette
 *   bg-deep    #191a21   darkest — header bar, titlebar strips
 *   bg-base    #282a36   main chat background
 *   bg-panel   #21222c   sidebars / input area
 *   bg-raised  #44475a   hover, selection, active items
 *   border     #44475a   subtle dividers
 *   comment    #6272a4   muted text, labels
 *   fg         #f8f8f2   primary text
 *   cyan       #8be9fd   sender names, accent
 *   green      #50fa7b   self name, connected status
 *   orange     #ffb86c   args hints, warning
 *   pink/purple #bd93f9  titles, buttons, focus rings
 *   red        #ff5555   errors, danger
 *   yellow     #f1fa8c   self messages
 */

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

.chat-wrapper {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 13px;
    color: #f8f8f2;
}

/* ── Layout ─────────────────────────────────────────── */

.chat-wrapper .container {
    display: flex;
    flex-direction: column;
}

.chat-wrapper .header {
    background: linear-gradient(135deg, #191a21 0%, #1f2029 100%);
    border-bottom: 1px solid #44475a;
    padding: 0 16px;
    height: 48px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.chat-wrapper .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-wrapper .title {
    font-weight: 700;
    font-size: 16px;
    color: #bd93f9;
    letter-spacing: 0.03em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 16px;
}

.chat-wrapper .chat-platform-links {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-wrapper .chat-platform-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(189, 147, 249, 0.1);
    border: 1px solid rgba(189, 147, 249, 0.3);
    color: #bd93f9;
    font-size: 16px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.chat-wrapper .chat-platform-links a:hover {
    background: rgba(189, 147, 249, 0.2);
    border-color: #bd93f9;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(189, 147, 249, 0.3);
}

.chat-wrapper .chat-platform-links a:active {
    transform: translateY(0);
}

.chat-wrapper .matrix-logo {
    font-weight: 700;
    font-size: 13px;
    font-family: 'Consolas', 'Courier New', monospace;
    letter-spacing: -1px;
}

/* 2-column main area (channels hidden) */
.chat-wrapper .main {
    display: grid;
    grid-template-columns: 1fr 180px;
    overflow: hidden;
}

/* ── Sidebars ────────────────────────────────────────── */

.chat-wrapper .channels-sidebar {
    display: none;
}

.chat-wrapper .channels-sidebar,
.chat-wrapper .users-sidebar {
    background: #21222c;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-wrapper .users-sidebar    { border-left:  1px solid #44475a; }

.chat-wrapper .sidebar-header {
    background: #191a21;
    padding: 0 14px;
    height: 36px;
    display: flex;
    align-items: center;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6272a4;
    border-bottom: 1px solid #44475a;
    flex-shrink: 0;
}

/* Channel list */
.chat-wrapper .channel-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.chat-wrapper .channel-item {
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 4px;
    margin: 1px 6px;
    color: #6272a4;
    user-select: none;
    transition: background 0.1s, color 0.1s;
}

.chat-wrapper .channel-item:hover  { background: #44475a; color: #f8f8f2; }
.chat-wrapper .channel-item.active { background: #44475a; color: #bd93f9; font-weight: 600; }

.chat-wrapper .unread-badge {
    background: #bd93f9;
    color: #191a21;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
}

/* User list */
.chat-wrapper .user-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.chat-wrapper .user-count {
    color: #6272a4;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 4px 14px 8px;
}

.chat-wrapper .user-group-header {
    color: #6272a4;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 10px 14px 4px;
}

.chat-wrapper .user-item {
    padding: 4px 12px;
    cursor: pointer;
    border-radius: 4px;
    margin: 1px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    color: #f8f8f2;
    transition: background 0.1s;
}

.chat-wrapper .user-item:hover { background: #44475a; }
.chat-wrapper .user-item.self  { color: #50fa7b; font-weight: 600; }

.chat-wrapper .typing-indicator {
    color: #6272a4;
    font-size: 11px;
    font-style: italic;
    padding: 8px 14px 4px;
    animation: pulse 1.5s ease-in-out infinite;
}

/* ── Chat center ─────────────────────────────────────── */

.chat-wrapper .chat-container {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #282a36;
}

.chat-wrapper .topic {
    background: #191a21;
    padding: 0 16px;
    height: 36px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #44475a;
    font-size: 12px;
    color: #6272a4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.chat-wrapper .messages-wrap {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.chat-wrapper .messages {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.chat-wrapper .messages::-webkit-scrollbar        { width: 8px; }
.chat-wrapper .messages::-webkit-scrollbar-track  { background: transparent; }
.chat-wrapper .messages::-webkit-scrollbar-thumb  { background: #44475a; border-radius: 4px; }
.chat-wrapper .messages::-webkit-scrollbar-thumb:hover { background: #6272a4; }

/* ── Messages ────────────────────────────────────────── */

.chat-wrapper .message {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 3px 6px;
    word-break: break-word;
    cursor: default;
    border-radius: 4px;
}

.chat-wrapper .message:hover { background: #21222c; }

.chat-wrapper .message.mentioned {
    background: rgba(189, 147, 249, 0.07);
    border-left: 2px solid #bd93f9;
    padding-left: 4px;
}

.chat-wrapper .message.mentioned:hover {
    background: rgba(189, 147, 249, 0.13);
}

.chat-wrapper .message-time {
    color: #6272a4;
    font-size: 11px;
    min-width: 42px;
    flex-shrink: 0;
    font-family: 'Consolas', monospace;
}

.chat-wrapper .message-sender {
    color: #8be9fd;
    font-weight: 600;
    min-width: 90px;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.chat-wrapper .message-sender.self { color: #f1fa8c; }

.chat-wrapper .message-content {
    color: #f8f8f2;
    flex: 1;
    overflow-wrap: break-word;
    line-height: 1.5;
}

.chat-wrapper .message-content a {
    color: #8be9fd;
    text-decoration: none;
    font-weight: 600;
}

.chat-wrapper .message-content a:hover { text-decoration: underline; }

.chat-wrapper .mention {
    color: #bd93f9;
    font-weight: 600;
    cursor: default;
}

.chat-wrapper .chat-image {
    max-width: 300px;
    max-height: 300px;
    display: block;
    margin-top: 4px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #44475a;
}

.chat-wrapper .chat-image:hover { opacity: 0.85; }

.chat-wrapper .system-message {
    color: #6272a4;
    font-style: italic;
    padding: 1px 0;
    font-size: 12px;
}

.chat-wrapper .error-message {
    color: #ff5555;
    padding: 1px 0;
    font-size: 12px;
}

.chat-wrapper .edited-tag {
    color: #6272a4;
    font-size: 10px;
    font-style: italic;
    margin-left: 4px;
    align-self: center;
}

.chat-wrapper .reaction-bar {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 2px 0 2px 146px;
}

.chat-wrapper .reaction-pill {
    background: #44475a;
    border: 1px solid #6272a4;
    border-radius: 12px;
    padding: 1px 8px;
    font-size: 12px;
    cursor: default;
    user-select: none;
    transition: background 0.1s;
}

.chat-wrapper .reaction-pill.self {
    background: #44475a;
    border-color: #bd93f9;
    color: #bd93f9;
}

/* ── Input area ──────────────────────────────────────── */

.chat-wrapper .input-container {
    border-top: 1px solid #44475a;
    background: linear-gradient(180deg, #1f2029 0%, #21222c 100%);
    padding: 12px 16px;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.3);
}

/* ── Autocomplete popup ──────────────────────────────── */

.chat-wrapper .autocomplete-popup {
    position: absolute;
    bottom: calc(100% - 10px);
    left: 12px;
    right: 12px;
    background: #21222c;
    border: 1px solid #44475a;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.6);
    max-height: 220px;
    overflow-y: auto;
    z-index: 200;
}

.chat-wrapper .ac-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 7px 14px;
    cursor: pointer;
    border-bottom: 1px solid #282a36;
}

.chat-wrapper .ac-item:last-child { border-bottom: none; }

.chat-wrapper .ac-item:hover,
.chat-wrapper .ac-item.selected { background: #44475a; }

.chat-wrapper .ac-label {
    color: #bd93f9;
    font-weight: 700;
    min-width: 90px;
    flex-shrink: 0;
    font-size: 13px;
}

.chat-wrapper .ac-hint {
    color: #ffb86c;
    font-size: 12px;
    flex-shrink: 0;
    font-family: 'Consolas', monospace;
}

.chat-wrapper .ac-desc {
    color: #6272a4;
    font-size: 12px;
    margin-left: auto;
    text-align: right;
}

.chat-wrapper .connection-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-wrapper .message-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-wrapper .auth-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.chat-wrapper .auth-tabs .tab {
    background: #44475a;
    color: #6272a4;
    padding: 8px 18px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px 4px 0 0;
    border: none;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}

.chat-wrapper .auth-tabs .tab:hover  { background: #4e5167; color: #f8f8f2; }
.chat-wrapper .auth-tabs .tab.active { background: #bd93f9; color: #191a21; }

.chat-wrapper .auth-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.chat-wrapper .auth-fields input { flex: 1; min-width: 140px; }

.chat-wrapper input {
    background: #282a36;
    border: 1px solid #44475a;
    color: #f8f8f2;
    padding: 8px 12px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    transition: border-color 0.15s;
}

.chat-wrapper input:focus { outline: none; border-color: #bd93f9; }

.chat-wrapper button {
    background: #bd93f9;
    border: none;
    color: #191a21;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    transition: background 0.1s;
}

.chat-wrapper button:hover    { background: #caa8ff; }
.chat-wrapper button:active   { background: #a87ef5; }
.chat-wrapper button:disabled { background: #44475a; color: #6272a4; cursor: not-allowed; }

.chat-wrapper #messageInput { flex: 1; }

.chat-wrapper #disconnectBtn {
    background: transparent;
    border: 1px solid #ff5555;
    color: #ff5555;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
}

.chat-wrapper #disconnectBtn:hover { background: #ff5555; color: #191a21; }

/* ── Status indicator ────────────────────────────────── */

.chat-wrapper .status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #6272a4; }

.chat-wrapper .status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.chat-wrapper .status-indicator.disconnected { background: #ff5555; }
.chat-wrapper .status-indicator.connecting   { background: #ffb86c; animation: pulse 1.5s ease-in-out infinite; }
.chat-wrapper .status-indicator.connected    { background: #50fa7b; }

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

/* ── Context menu ────────────────────────────────────── */

.chat-wrapper .context-menu {
    position: fixed;
    display: none;
    z-index: 1000;
    background: #21222c;
    border: 1px solid #44475a;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    min-width: 170px;
    padding: 4px 0;
}

.chat-wrapper .ctx-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    color: #f8f8f2;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: normal;
    border-radius: 0;
}

.chat-wrapper .ctx-item:hover  { background: #44475a; color: #f8f8f2; }
.chat-wrapper .ctx-item.danger { color: #ff5555; }
.chat-wrapper .ctx-item.danger:hover { background: #ff5555; color: #191a21; }

.chat-wrapper .ctx-sep {
    border-top: 1px solid #44475a;
    margin: 4px 0;
}

/* ── Scrollbars (shared) ─────────────────────────────── */

.chat-wrapper .channel-list::-webkit-scrollbar,
.chat-wrapper .user-list::-webkit-scrollbar    { width: 4px; }

.chat-wrapper .channel-list::-webkit-scrollbar-track,
.chat-wrapper .user-list::-webkit-scrollbar-track  { background: transparent; }

.chat-wrapper .channel-list::-webkit-scrollbar-thumb,
.chat-wrapper .user-list::-webkit-scrollbar-thumb  { background: #44475a; border-radius: 4px; }

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 700px) {
    .main { grid-template-columns: 1fr 0; }
    .channels-sidebar, .users-sidebar { display: none; }
    
    .chat-wrapper .title {
        font-size: 14px;
        gap: 8px;
    }
    
    .chat-wrapper .chat-platform-links {
        gap: 6px;
    }
    
    .chat-wrapper .chat-platform-links a {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

