/* ═══════════════════════════════════════════════════════════
   CONNOR MERK CHAT — Geist-Inspired Design System
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Variables ──────────────────────────────────────── */
:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    --transition-fast: 120ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms ease;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.2);

    --sidebar-width: 340px;
    --info-panel-width: 320px;
    --chat-input-max: 720px;
    --header-height: 60px;
}

/* Dark Theme (default) */
[data-theme="dark"] {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-tertiary: #171717;
    --bg-elevated: #1a1a1a;
    --bg-hover: #1f1f1f;
    --bg-active: #252525;

    --border-primary: #2e2e2e;
    --border-secondary: #3a3a3a;

    --text-primary: #ededed;
    --text-secondary: #a1a1a1;
    --text-tertiary: #666666;

    --accent: #0070f3;
    --accent-hover: #0060df;
    --accent-light: rgba(0,112,243,0.15);
    --accent-text: #ffffff;

    --msg-sent-bg: #0070f3;
    --msg-sent-text: #ffffff;
    --msg-received-bg: #1e1e1e;
    --msg-received-text: #ededed;
    --msg-system-bg: transparent;
    --msg-system-text: #666666;

    --success: #00cc88;
    --warning: #f5a623;
    --error: #ee0000;
    --info: #0070f3;

    --scrollbar-track: transparent;
    --scrollbar-thumb: #333333;
    --scrollbar-thumb-hover: #444444;

    --online-color: #00cc88;
    --unread-badge: #0070f3;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --bg-tertiary: #f5f5f5;
    --bg-elevated: #ffffff;
    --bg-hover: #f0f0f0;
    --bg-active: #e8e8e8;

    --border-primary: #eaeaea;
    --border-secondary: #d4d4d4;

    --text-primary: #171717;
    --text-secondary: #666666;
    --text-tertiary: #999999;

    --accent: #0070f3;
    --accent-hover: #005bb5;
    --accent-light: rgba(0,112,243,0.1);
    --accent-text: #ffffff;

    --msg-sent-bg: #0070f3;
    --msg-sent-text: #ffffff;
    --msg-received-bg: #f0f0f0;
    --msg-received-text: #171717;
    --msg-system-bg: transparent;
    --msg-system-text: #999999;

    --success: #00a870;
    --warning: #e08e0b;
    --error: #e00;
    --info: #0070f3;

    --scrollbar-track: transparent;
    --scrollbar-thumb: #d4d4d4;
    --scrollbar-thumb-hover: #bbb;

    --online-color: #00a870;
    --unread-badge: #0070f3;
}

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

input, textarea, button, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
    outline: none;
}
.btn:focus-visible { box-shadow: 0 0 0 2px var(--accent); }

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

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

.btn-danger {
    background: transparent;
    color: var(--error);
    border-color: var(--border-primary);
}
.btn-danger:hover { background: rgba(238,0,0,0.1); border-color: var(--error); }

.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-loader {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn:active { transform: scale(0.95); }

/* ── Form Elements ─────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}
input:focus, textarea:focus {
    border-color: var(--accent);
}
input::placeholder, textarea::placeholder {
    color: var(--text-tertiary);
}
textarea { resize: vertical; }

.search-input-wrapper {
    position: relative;
}
.search-input-wrapper .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}
.search-input-wrapper input {
    padding-left: 36px;
}

/* ── Avatar ────────────────────────────────────────────── */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-secondary);
    overflow: hidden;
    flex-shrink: 0;
    font-size: 16px;
    position: relative;
}
.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.avatar-sm { width: 36px; height: 36px; font-size: 14px; }
.avatar-md { width: 44px; height: 44px; font-size: 18px; }
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }
.avatar-xl { width: 80px; height: 80px; font-size: 32px; }

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

/* ── Spinner ───────────────────────────────────────────── */
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-primary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

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

/* ═══════════════════════════════════════════════════════════
   AUTH SCREEN
   ═══════════════════════════════════════════════════════════ */
.auth-screen {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}
.auth-logo-icon {
    margin-bottom: 16px;
}
.auth-logo h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}
.auth-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

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

.auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-error {
    background: rgba(238,0,0,0.1);
    color: var(--error);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid rgba(238,0,0,0.2);
}

/* ═══════════════════════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════════════════════ */
.app-screen {
    height: 100%;
    display: flex;
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-primary);
    height: var(--header-height);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}
.sidebar-user:hover { background: var(--bg-hover); }
.sidebar-username {
    font-weight: 600;
    font-size: 15px;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-actions {
    display: flex;
    gap: 2px;
}

.sidebar-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-primary);
}

/* ── Conversation List ────────────────────────────────── */
.conversation-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid transparent;
    position: relative;
}
.conversation-item:hover { background: var(--bg-hover); }
.conversation-item.active { background: var(--bg-active); }
.conversation-item.pinned::before {
    content: '';
    position: absolute;
    top: 10px;
    right: 12px;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0.5;
}

.conv-info {
    flex: 1;
    min-width: 0;
}
.conv-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.conv-name {
    font-weight: 500;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.conv-time {
    font-size: 11px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}
.conv-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}
.conv-preview {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.conv-badge {
    background: var(--unread-badge);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    flex-shrink: 0;
}

.conv-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* ── Chat Area ────────────────────────────────────────── */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-primary);
    position: relative;
}

.empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.empty-state-content {
    text-align: center;
    color: var(--text-tertiary);
}
.empty-state-icon {
    margin-bottom: 16px;
    opacity: 0.3;
}
.empty-state-content h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.empty-state-content p { font-size: 14px; }

.chat-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ── Chat Header ──────────────────────────────────────── */
.chat-header {
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: var(--header-height);
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    gap: 8px;
    flex-shrink: 0;
}
.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-md);
}
.chat-header-info:hover { background: var(--bg-hover); }
.chat-header-text { min-width: 0; }
.chat-header-text h3 {
    font-size: 15px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-header-status {
    font-size: 12px;
    color: var(--text-tertiary);
}
.chat-header-status.online { color: var(--online-color); }
.chat-header-actions {
    display: flex;
    gap: 2px;
}

/* ── Message Search Bar ───────────────────────────────── */
.message-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
}
.message-search-bar input {
    flex: 1;
}

/* ── Messages Container ──────────────────────────────── */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: auto;
}

/* ── Message Bubble ──────────────────────────────────── */
.message-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 70%;
    animation: messageIn 0.2s ease;
}
.message-wrapper.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.message-wrapper.received {
    align-self: flex-start;
}
.message-wrapper.system {
    align-self: center;
    max-width: 90%;
}

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

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    color: var(--text-secondary);
}
.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.message-avatar.hidden { visibility: hidden; }

.message-bubble {
    padding: 8px 12px;
    border-radius: var(--radius-lg);
    position: relative;
    word-break: break-word;
    min-width: 60px;
}
.sent .message-bubble {
    background: var(--msg-sent-bg);
    color: var(--msg-sent-text);
    border-bottom-right-radius: 4px;
}
.received .message-bubble {
    background: var(--msg-received-bg);
    color: var(--msg-received-text);
    border-bottom-left-radius: 4px;
}
.system .message-bubble {
    background: none;
    color: var(--msg-system-text);
    font-size: 12px;
    text-align: center;
    font-style: italic;
    padding: 4px 12px;
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--accent);
}
.sent .message-sender { display: none; }

.message-reply {
    background: rgba(0,0,0,0.15);
    border-left: 2px solid var(--accent);
    padding: 4px 8px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 4px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0.85;
}
.received .message-reply {
    background: rgba(0,0,0,0.08);
}
.message-reply-name {
    font-weight: 600;
    display: block;
    font-size: 11px;
}
.message-reply-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
    display: block;
}

.message-content {
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.45;
}

.message-attachments {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.message-attachment-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: opacity var(--transition-fast);
    object-fit: cover;
}
.message-attachment-image:hover { opacity: 0.9; }

.message-attachment-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.12);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    text-decoration: none;
    color: inherit;
}
.received .message-attachment-file {
    background: rgba(0,0,0,0.06);
}
.message-attachment-file:hover { background: rgba(0,0,0,0.2); text-decoration: none; }
.message-attachment-file-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}
.message-attachment-file-info {
    min-width: 0;
}
.message-attachment-file-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.message-attachment-file-size {
    font-size: 11px;
    opacity: 0.7;
}

.message-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 2px;
}
.message-time {
    font-size: 11px;
    opacity: 0.6;
}
.message-edited {
    font-size: 10px;
    opacity: 0.5;
    font-style: italic;
}

.message-status {
    display: flex;
    align-items: center;
}
.message-status svg {
    width: 14px;
    height: 14px;
}
.message-status.read svg { color: #34b7f1; }
.sent .message-status.read svg { color: rgba(255,255,255,0.9); }

.message-deleted {
    font-style: italic;
    opacity: 0.5;
}

/* Message Reactions */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    background: rgba(0,0,0,0.1);
    border-radius: var(--radius-full);
    font-size: 12px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
}
.reaction-badge:hover { border-color: var(--border-secondary); }
.reaction-badge.own { border-color: var(--accent); background: var(--accent-light); }
.reaction-count { font-size: 11px; }

/* Date Separator */
.date-separator {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 16px 0;
}
.date-separator::before,
.date-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-primary);
}
.date-separator-text {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* ── Typing Indicator ─────────────────────────────────── */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 16px 8px;
    font-size: 13px;
    color: var(--text-tertiary);
}
.typing-dots {
    display: flex;
    gap: 3px;
}
.typing-dots span {
    width: 4px;
    height: 4px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Reply / Edit Preview ─────────────────────────────── */
.reply-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
    border-left: 3px solid var(--accent);
}
.edit-preview {
    border-left-color: var(--warning);
}
.reply-preview-content {
    flex: 1;
    min-width: 0;
}
.reply-preview-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    display: block;
}
.edit-preview .reply-preview-name {
    color: var(--warning);
}
.reply-preview-text {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}
.reply-preview-close {
    flex-shrink: 0;
}

/* ── File Preview ─────────────────────────────────────── */
.file-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
    overflow-x: auto;
}
.file-preview-items {
    display: flex;
    gap: 8px;
    flex: 1;
}
.file-preview-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 12px;
    max-width: 180px;
}
.file-preview-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-preview-item-remove {
    cursor: pointer;
    color: var(--text-tertiary);
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}
.file-preview-item-remove:hover { color: var(--error); }

/* ── Chat Input ───────────────────────────────────────── */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 8px 12px;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}
.chat-input-wrapper {
    flex: 1;
    min-width: 0;
}
.chat-input-wrapper textarea {
    width: 100%;
    resize: none;
    border: 1px solid var(--border-primary);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    max-height: 120px;
    line-height: 1.4;
    outline: none;
    transition: border-color var(--transition-fast);
}
.chat-input-wrapper textarea:focus {
    border-color: var(--accent);
}

.send-btn {
    color: var(--accent) !important;
}
.send-btn:hover {
    background: var(--accent-light) !important;
}

/* ── Info Panel ───────────────────────────────────────── */
.info-panel {
    width: var(--info-panel-width);
    min-width: var(--info-panel-width);
    height: 100%;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.info-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: var(--header-height);
    border-bottom: 1px solid var(--border-primary);
}
.info-panel-header h3 {
    font-size: 15px;
    font-weight: 600;
}
.info-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
}
.info-panel-content .avatar {
    margin: 0 auto 16px;
}
.info-section {
    margin-bottom: 24px;
}
.info-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}
.info-section-value {
    font-size: 14px;
    color: var(--text-primary);
    word-break: break-word;
}
.info-member-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.info-member {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}
.info-member:hover { background: var(--bg-hover); }
.info-member-name {
    font-size: 13px;
    font-weight: 500;
}
.info-member-role {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.info-action-btn {
    width: 100%;
    margin-top: 8px;
}

/* ═══════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease;
    backdrop-filter: blur(4px);
}
.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 460px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s ease;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-primary);
}
.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}
.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-primary);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

/* ── User Search Results ──────────────────────────────── */
.user-search-results {
    margin-top: 12px;
    max-height: 300px;
    overflow-y: auto;
}
.user-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.user-result:hover { background: var(--bg-hover); }
.user-result-info {
    flex: 1;
    min-width: 0;
}
.user-result-name {
    font-weight: 500;
    font-size: 14px;
}
.user-result-email {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ── Selected Members ─────────────────────────────────── */
.selected-members {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.selected-member-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
}
.selected-member-chip-remove {
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    opacity: 0.7;
}
.selected-member-chip-remove:hover { opacity: 1; }

/* ── Profile Modal ────────────────────────────────────── */
.profile-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.theme-toggle {
    display: flex;
    gap: 8px;
}
.theme-option {
    flex: 1;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    text-align: center;
}
.theme-option:hover { border-color: var(--border-secondary); }
.theme-option.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════
   EMOJI PICKER
   ═══════════════════════════════════════════════════════════ */
.emoji-picker {
    position: fixed;
    background: var(--bg-elevated);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    z-index: 1001;
    width: 320px;
}
.emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    max-height: 240px;
    overflow-y: auto;
}
.emoji-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 20px;
    transition: background var(--transition-fast);
    border: none;
    background: none;
}
.emoji-item:hover { background: var(--bg-hover); }

/* ═══════════════════════════════════════════════════════════
   CONTEXT MENU
   ═══════════════════════════════════════════════════════════ */
.context-menu {
    position: fixed;
    background: var(--bg-elevated);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    z-index: 1002;
    min-width: 180px;
    animation: menuIn 0.12s ease;
}
.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    transition: background var(--transition-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.context-menu-item:hover { background: var(--bg-hover); }
.context-menu-item.danger { color: var(--error); }
.context-menu-separator {
    height: 1px;
    background: var(--border-primary);
    margin: 4px 0;
}

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

/* ═══════════════════════════════════════════════════════════
   IMAGE VIEWER
   ═══════════════════════════════════════════════════════════ */
.image-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}
.image-viewer img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: var(--radius-md);
}
.image-viewer-close {
    position: absolute;
    top: 16px;
    right: 16px;
    color: #fff !important;
}
.image-viewer-close:hover { background: rgba(255,255,255,0.1) !important; }

/* ═══════════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    color: var(--text-primary);
    animation: toastIn 0.3s ease;
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.info { border-left: 3px solid var(--info); }

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

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        z-index: 10;
        width: 100%;
        min-width: 100%;
        transition: transform var(--transition-normal);
    }
    .sidebar.hidden {
        transform: translateX(-100%);
    }
    .chat-area { width: 100%; }
    .mobile-back-btn { display: flex !important; }
    .info-panel {
        position: absolute;
        right: 0;
        z-index: 11;
        width: 100%;
        min-width: 100%;
    }
    .message-wrapper { max-width: 85%; }
}

@media (max-width: 480px) {
    .modal { width: 95%; }
    .emoji-picker { width: 280px; }
}

/* ═══════════════════════════════════════════════════════════
   LOAD MORE BUTTON
   ═══════════════════════════════════════════════════════════ */
.load-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    margin: 0 auto 8px;
}
.load-more-btn:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════
   UNREAD SEPARATOR
   ═══════════════════════════════════════════════════════════ */
.unread-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 12px 0;
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
}
.unread-separator::before,
.unread-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--accent);
    opacity: 0.3;
}
.unread-separator::before { margin-right: 12px; }
.unread-separator::after { margin-left: 12px; }

/* ═══════════════════════════════════════════════════════════
   MISCELLANEOUS
   ═══════════════════════════════════════════════════════════ */
.highlight-message {
    animation: highlightFlash 1.5s ease;
}
@keyframes highlightFlash {
    0%, 100% { background: transparent; }
    30% { background: var(--accent-light); }
}

.pinned-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
    font-size: 13px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background var(--transition-fast);
}
.pinned-banner:hover { background: var(--bg-hover); }
.pinned-banner svg {
    flex-shrink: 0;
    color: var(--accent);
}

/* Group avatar colors */
.avatar-color-0 { background: #2d1b69; color: #a78bfa; }
.avatar-color-1 { background: #1b3a4b; color: #67e8f9; }
.avatar-color-2 { background: #3b2f0a; color: #fbbf24; }
.avatar-color-3 { background: #1a3024; color: #6ee7b7; }
.avatar-color-4 { background: #3b1c32; color: #f9a8d4; }
.avatar-color-5 { background: #2e1a0e; color: #fdba74; }
