/*
 * 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 #9b87f5  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: #f8f5ff;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-wrapper .chat-title-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.chat-wrapper .chat-title-text {
    color: #f4f1ff;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.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: #9b87f5;
    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: #9b87f5;
    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: flex;
    position: relative;
    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;
}

/* Users panel — docked on desktop (right), drawer on mobile */
.chat-wrapper .users-sidebar {
    position: relative;
    flex-shrink: 0;
    width: 240px;
    border-left: 1px solid #44475a;
    border-right: none;
    transform: none;
    z-index: 20;
    display: none;
}

.chat-wrapper .users-sidebar.open {
    display: flex;
}

.chat-wrapper .users-backdrop {
    display: none;
}

@media (max-width: 700px) {
    .chat-wrapper .users-sidebar {
        position: absolute;
        top: 0;
        right: 0;
        left: auto;
        bottom: 0;
        max-width: 80%;
        display: flex;
        transform: translateX(100%);
        transition: transform 0.28s ease;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.45);
        border-left: 1px solid #44475a;
        border-right: none;
    }

    .chat-wrapper .users-sidebar.open {
        transform: translateX(0);
    }

    .chat-wrapper .users-backdrop {
        display: block;
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.28s ease;
        z-index: 15;
    }

    .chat-wrapper .users-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }
}

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

.chat-wrapper .users-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    color: #6272a4;
    cursor: pointer;
    font-size: 14px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.chat-wrapper .users-close-btn:hover {
    background: #44475a;
    color: #f8f8f2;
}

/* Header button that toggles the users drawer */
.chat-wrapper .users-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(255, 255, 255, 0.04);
    color: #b5adc9;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chat-wrapper .users-toggle-btn:hover {
    background: rgba(126, 89, 255, 0.14);
    border-color: rgba(176, 148, 255, 0.35);
    color: #f8f8f2;
}

.chat-wrapper .users-toggle-btn.active {
    background: linear-gradient(140deg, #a07cff, #7e59ff);
    border-color: rgba(176, 148, 255, 0.45);
    color: #fff;
}

.chat-wrapper .chat-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(255, 255, 255, 0.04);
    color: #b5adc9;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chat-wrapper .chat-close-btn:hover {
    background: rgba(255, 85, 85, 0.14);
    border-color: rgba(255, 85, 85, 0.4);
    color: #ff5555;
}

@media (max-width: 768px) {
    .chat-wrapper .chat-close-btn {
        display: inline-flex;
    }
}

/* 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: #9b87f5; font-weight: 600; }

.chat-wrapper .unread-badge {
    background: #9b87f5;
    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;
    flex: 1;
    min-width: 0;
}

.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;
    min-height: 0;
}

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

.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 #9b87f5;
    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: #9b87f5;
    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: #9b87f5;
    color: #9b87f5;
}

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

.chat-wrapper .input-container {
    border-top: 1px solid #44475a;
    background: linear-gradient(180deg, #1f2029 0%, #21222c 100%);
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    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: #9b87f5;
    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 .guest-nick-prompt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #44475a;
    background: #21222c;
    border-radius: 6px;
    flex-wrap: wrap;
}

.chat-wrapper .guest-nick-label {
    color: #6272a4;
    font-size: 12px;
    font-weight: 600;
}

.chat-wrapper .guest-nick-input {
    flex: 1;
    min-width: 180px;
}

.chat-wrapper .guest-nick-actions {
    display: flex;
    gap: 8px;
}

.chat-wrapper .secondary-btn {
    position: relative;
    overflow: hidden;
    background: linear-gradient(140deg, #3c4464 0%, #33405f 100%);
    border: 1px solid rgba(255, 255, 255, 0.09);
    color: #f8f5ff;
    border-radius: 12px;
    font-weight: 600;
    transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s;
}

.chat-wrapper .secondary-btn::after {
    content: '';
    position: absolute;
    top: -120%;
    left: -42%;
    width: 34%;
    height: 340%;
    transform: rotate(18deg) translateX(-220%);
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0.5),
        rgba(255, 255, 255, 0)
    );
    opacity: 0;
    pointer-events: none;
}

.chat-wrapper .secondary-btn:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
}

.chat-wrapper .secondary-btn:hover::after,
.chat-wrapper .secondary-btn:focus-visible::after {
    opacity: 1;
    animation: buttonShimmer 0.72s ease-out;
}

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

.chat-wrapper .auth-tabs .tab {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.04);
    color: #b5adc9;
    padding: 8px 18px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    cursor: pointer;
    transition: transform 0.16s, border-color 0.16s, background 0.16s, color 0.16s, box-shadow 0.16s;
}

.chat-wrapper .auth-tabs .tab::after {
    content: '';
    position: absolute;
    top: -120%;
    left: -42%;
    width: 34%;
    height: 340%;
    transform: rotate(18deg) translateX(-220%);
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0.5),
        rgba(255, 255, 255, 0)
    );
    opacity: 0;
    pointer-events: none;
}

.chat-wrapper .auth-tabs .tab:hover {
    transform: translateY(-1px);
    background: rgba(126, 89, 255, 0.14);
    border-color: rgba(176, 148, 255, 0.35);
    color: #f8f8f2;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

.chat-wrapper .auth-tabs .tab:hover::after,
.chat-wrapper .auth-tabs .tab:focus-visible::after {
    opacity: 1;
    animation: buttonShimmer 0.72s ease-out;
}

.chat-wrapper .auth-tabs .tab.active {
    background: linear-gradient(140deg, #a07cff 0%, #7e59ff 100%);
    border-color: rgba(176, 148, 255, 0.45);
    color: #f8f5ff;
}

.chat-wrapper .auth-tabs .tab.active:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
}

.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: 10px;
    font-family: inherit;
    font-size: 13px;
    transition: border-color 0.15s;
}

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

.chat-wrapper button {
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.chat-wrapper #connectBtn,
.chat-wrapper #sendBtn {
    position: relative;
    overflow: hidden;
    color: #f8f5ff;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 10px 20px;
    border-radius: 12px;
    border: 1px solid rgba(176, 148, 255, 0.45);
    background: linear-gradient(140deg, #a07cff 0%, #7e59ff 100%);
    transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s;
}

.chat-wrapper #connectBtn::after,
.chat-wrapper #sendBtn::after {
    content: '';
    position: absolute;
    top: -120%;
    left: -42%;
    width: 34%;
    height: 340%;
    transform: rotate(18deg) translateX(-220%);
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0.5),
        rgba(255, 255, 255, 0)
    );
    opacity: 0;
    pointer-events: none;
}

.chat-wrapper #connectBtn:hover:not(:disabled),
.chat-wrapper #sendBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
}

.chat-wrapper #connectBtn:hover:not(:disabled)::after,
.chat-wrapper #sendBtn:hover:not(:disabled)::after,
.chat-wrapper #connectBtn:focus-visible::after,
.chat-wrapper #sendBtn:focus-visible::after {
    opacity: 1;
    animation: buttonShimmer 0.72s ease-out;
}

.chat-wrapper #connectBtn:focus-visible,
.chat-wrapper #sendBtn:focus-visible {
    outline: 2px solid rgba(176, 155, 255, 0.65);
    outline-offset: 2px;
}

.chat-wrapper #connectBtn:disabled,
.chat-wrapper #sendBtn:disabled {
    background: #44475a;
    border-color: #44475a;
    color: #6272a4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.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;
    border-radius: 10px;
    transition: background 0.16s, color 0.16s, transform 0.16s;
}

.chat-wrapper #disconnectBtn:hover {
    background: #ff5555;
    color: #191a21;
    transform: translateY(-1px);
}

@keyframes buttonShimmer {
    from {
        transform: rotate(18deg) translateX(-220%);
    }
    to {
        transform: rotate(18deg) translateX(520%);
    }
}

/* ── 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) {
    .chat-wrapper .channels-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;
    }
}


/* Chat Overlay */
.chat-overlay {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 900px;
    height: 100vh;
    height: 100dvh;
    z-index: 9999;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.5);
}

.chat-overlay.active {
    right: 0;
}

.chat-overlay.is-dragging {
    transition: none;
}

.chat-overlay.is-dragging .chat-wrapper {
    transition: none;
}

.chat-overlay::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: -1;
}

.chat-overlay.active::before {
    opacity: 1;
    pointer-events: auto;
}

.chat-wrapper {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: #191a21;
}

.chat-wrapper .container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0;
    max-width: none;
    width: 100%;
    padding: 0 !important;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

.chat-wrapper .header {
    position: relative;
    border-bottom: 1px solid #44475a;
}

.chat-wrapper .main {
    flex: 1;
    min-height: 0;
    width: 100%;
}

.chat-wrapper .header,
.chat-wrapper .chat-container,
.chat-wrapper .messages-wrap,
.chat-wrapper .input-container {
    width: 100%;
}

/* Live chat widget */
.live-chat-widget {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
}

.live-chat-widget > * {
    pointer-events: auto;
}

.live-chat-launcher {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 1px solid rgba(176, 148, 255, 0.45);
    border-radius: 50%;
    background: linear-gradient(140deg, #a07cff 0%, #7e59ff 100%);
    color: #f8f5ff;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(126, 89, 255, 0.4);
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.live-chat-launcher::after {
    content: '';
    position: absolute;
    top: -120%;
    left: -42%;
    width: 34%;
    height: 340%;
    transform: rotate(18deg) translateX(-220%);
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0.5),
        rgba(255, 255, 255, 0)
    );
    opacity: 0;
    pointer-events: none;
}

.live-chat-launcher:hover {
    transform: translateY(-2px) scale(1.04);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
}

.live-chat-launcher:hover::after,
.live-chat-launcher:focus-visible::after {
    opacity: 1;
    animation: buttonShimmer 0.72s ease-out;
}

.live-chat-launcher:focus-visible {
    outline: 2px solid rgba(176, 155, 255, 0.65);
    outline-offset: 2px;
}

.live-chat-launcher:active {
    transform: translateY(0) scale(0.98);
}

.live-chat-launcher.hidden {
    display: none;
}

.live-chat-launcher-icon {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
}

.live-chat-status-dot {
    position: absolute;
    top: -4px;
    right: -6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #7e59ff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.live-chat-status-dot.disconnected {
    background: #ff5555;
    box-shadow: 0 0 0 1px rgba(255, 85, 85, 0.35);
}

.live-chat-status-dot.connecting {
    background: #ffb86c;
    box-shadow: 0 0 0 1px rgba(255, 184, 108, 0.35);
    animation: chatStatusPulse 1.5s ease-in-out infinite;
}

.live-chat-status-dot.connected {
    background: #50fa7b;
    box-shadow: 0 0 0 1px rgba(80, 250, 123, 0.35);
}

@keyframes chatStatusPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.35; }
}

.live-chat-widget .chat-preview-bubble {
    position: relative;
    right: auto;
    bottom: auto;
    max-width: min(300px, calc(100vw - 32px));
    border-radius: 16px 16px 4px 16px;
    animation: liveChatBubbleIn 0.28s ease-out;
}

.live-chat-widget .chat-preview-bubble::after {
    content: '';
    position: absolute;
    right: 22px;
    bottom: -7px;
    width: 14px;
    height: 14px;
    background: #21222c;
    border-right: 1px solid #44475a;
    border-bottom: 1px solid #44475a;
    transform: rotate(45deg);
    border-radius: 0 0 3px 0;
}

.live-chat-widget .chat-preview-bubble:hover {
    transform: translateY(-2px);
}

@keyframes liveChatBubbleIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat Preview Bubble */
.chat-preview-bubble {
    background: linear-gradient(135deg, #282a36, #21222c);
    border: 1px solid #44475a;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    z-index: 9997;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-preview-bubble:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
    border-color: #9b87f5;
}

.chat-preview-bubble.hidden {
    display: none;
}

.chat-preview-bubble .preview-sender {
    font-size: 11px;
    font-weight: 700;
    color: #8be9fd;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-preview-bubble .preview-message {
    font-size: 13px;
    color: #f8f8f2;
    line-height: 1.4;
    margin-bottom: 6px;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.chat-preview-bubble .preview-time {
    font-size: 10px;
    color: #6272a4;
    font-style: italic;
}

@keyframes chatPulse {
    0%, 100% {
        box-shadow: 0 6px 24px rgba(189, 147, 249, 0.4);
    }
    50% {
        box-shadow: 0 6px 32px rgba(189, 147, 249, 0.7);
    }
}

@media (max-width: 768px) {
    .chat-overlay {
        max-width: 100%;
    }

    .live-chat-launcher {
        width: 58px;
        height: 58px;
    }

    .live-chat-launcher-icon {
        font-size: 25px;
    }

    .live-chat-widget .chat-preview-bubble {
        max-width: calc(100vw - 32px);
    }
}
