/* ============================================
   FirstChat — Modern Messenger CSS
   Mobile-first, Telegram-style design
   ============================================ */

/* === CSS Variables === */
:root {
    --primary: #6C63FF;
    --primary-dark: #5A52D5;
    --primary-light: #8B85FF;
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --bg-chat: #0d1b2a;
    --bg-message-out: #2d2b6b;
    --bg-message-in: #1e2a3a;
    --bg-input: #1e2a3a;
    --bg-sidebar: #16213e;
    --bg-hover: rgba(108, 99, 255, 0.1);
    --text-primary: #e8e8f0;
    --text-secondary: #8b8b9e;
    --text-muted: #5a5a72;
    --border-color: rgba(108, 99, 255, 0.15);
    --danger: #ff4757;
    --success: #2ed573;
    --warning: #ffa502;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 18px;
    --transition: 0.2s ease;
    --sidebar-width: 360px;
    --header-height: 60px;
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8f0;
    --bg-chat: #e5ddd5;
    --bg-message-out: #d9fdd3;
    --bg-message-in: #ffffff;
    --bg-input: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-hover: rgba(108, 99, 255, 0.08);
    --text-primary: #1a1a2e;
    --text-secondary: #5a5a72;
    --text-muted: #8b8b9e;
    --border-color: rgba(0,0,0,0.08);
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* AMOLED theme */
[data-theme="amoled"] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #141414;
    --bg-chat: #000000;
    --bg-message-out: #1a1a3e;
    --bg-message-in: #111111;
    --bg-input: #111111;
    --bg-sidebar: #0a0a0a;
    --bg-hover: rgba(108, 99, 255, 0.1);
    --text-primary: #e8e8f0;
    --text-secondary: #8b8b9e;
    --border-color: rgba(255,255,255,0.06);
}

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* === Utilities === */
.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    width: 40px;
    height: 40px;
}
.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--primary);
}
.icon-btn svg {
    width: 22px;
    height: 22px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    gap: 8px;
}
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(108, 99, 255, 0.4);
}
.btn-block { width: 100%; }

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    font-weight: 600;
    font-size: 18px;
    color: white;
}
.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.avatar-sm { width: 36px; height: 36px; font-size: 14px; }
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }
.avatar-xl { width: 80px; height: 80px; font-size: 32px; }

/* === Auth Pages === */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}
.logo-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
}
.logo-icon svg { width: 100%; height: 100%; }
.auth-logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.auth-subtitle {
    color: var(--text-secondary);
    margin-top: 4px;
}

.auth-form .form-group {
    margin-bottom: 20px;
}
.auth-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.input-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}
.input-wrapper input {
    width: 100%;
    padding: 14px 14px 14px 42px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 15px;
    transition: var(--transition);
    outline: none;
}
.input-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}
.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.toggle-password {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 6px;
}
.toggle-password svg { width: 18px; height: 18px; }

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.checkbox-group {
    display: flex;
    align-items: center;
}
.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    color: var(--text-primary) !important;
}
.checkbox-label input[type="checkbox"] {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
}

.password-strength {
    margin-top: 8px;
}
.strength-bar {
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}
.strength-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s, background 0.3s;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-secondary);
}
.auth-footer a {
    font-weight: 600;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error {
    background: rgba(255, 71, 87, 0.15);
    color: var(--danger);
    border: 1px solid rgba(255, 71, 87, 0.3);
}
.alert-success {
    background: rgba(46, 213, 115, 0.15);
    color: var(--success);
    border: 1px solid rgba(46, 213, 115, 0.3);
}

/* === App Layout === */
.app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100%;
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.sidebar-header-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.sidebar-header-top h2 {
    flex: 1;
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.search-icon {
    position: absolute;
    left: 12px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}
.search-wrapper input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}
.search-wrapper input:focus {
    border-color: var(--primary);
    background: var(--bg-secondary);
}
.search-wrapper input::placeholder {
    color: var(--text-muted);
}

/* === Chat List === */
.chat-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}
.chat-item:hover {
    background: var(--bg-hover);
}
.chat-item.active {
    background: rgba(108, 99, 255, 0.15);
    border-left: 3px solid var(--primary);
}

.chat-item .avatar {
    position: relative;
}
.online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    background: var(--success);
    border-radius: 50%;
    border: 2px solid var(--bg-sidebar);
}

.chat-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.chat-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.chat-item-name {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-item-time {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 8px;
}
.chat-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.chat-item-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.chat-item-badge {
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    flex-shrink: 0;
    margin-left: 8px;
}
.chat-item-encrypted {
    color: var(--success);
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 2px;
}
.chat-item-encrypted svg {
    width: 12px;
    height: 12px;
}

/* === Menu === */
.menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.menu-overlay.active { display: block; }

.menu-panel {
    width: 300px;
    height: 100%;
    background: var(--bg-secondary);
    box-shadow: var(--shadow);
    overflow-y: auto;
    animation: slideInLeft 0.2s ease;
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.menu-user-info {
    padding: 24px 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    gap: 12px;
}
.menu-user-details {
    display: flex;
    flex-direction: column;
}
.menu-user-name {
    font-weight: 600;
    font-size: 16px;
    color: white;
}
.menu-username {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
}

.menu-nav {
    padding: 8px 0;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    color: var(--text-primary);
    transition: var(--transition);
    text-decoration: none !important;
}
.menu-item:hover {
    background: var(--bg-hover);
}
.menu-item svg {
    width: 22px;
    height: 22px;
    color: var(--text-secondary);
}
.menu-item-danger { color: var(--danger) !important; }
.menu-item-danger svg { color: var(--danger) !important; }

/* === Modals === */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1100;
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}
.modal-overlay.active {
    display: flex;
}

.modal-panel {
    width: 90%;
    max-width: 440px;
    max-height: 85vh;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Settings */
.settings-body {
    padding: 20px;
}
.settings-section {
    margin-bottom: 24px;
}
.settings-section h4 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary);
    margin-bottom: 12px;
}
.settings-avatar-section {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}
.settings-field {
    margin-bottom: 16px;
}
.settings-field label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}
.settings-field input,
.settings-field textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
    font-family: inherit;
    resize: vertical;
}
.settings-field input:focus,
.settings-field textarea:focus {
    border-color: var(--primary);
}

.settings-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}
.settings-toggle-info {
    flex: 1;
    min-width: 0;
}
.settings-toggle-info span {
    display: block;
    font-size: 14px;
    color: var(--text-primary);
}
.settings-toggle-desc {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.3;
}

.switch {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-tertiary);
    border-radius: 13px;
    transition: var(--transition);
}
.slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}
.switch input:checked + .slider {
    background: var(--primary);
}
.switch input:checked + .slider::before {
    transform: translateX(22px);
}

.theme-options {
    display: flex;
    gap: 8px;
}
.theme-btn {
    flex: 1;
    padding: 10px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition);
}
.theme-btn:hover, .theme-btn.active {
    border-color: var(--primary);
    background: rgba(108, 99, 255, 0.1);
}

/* User search results */
.user-search-results {
    margin-top: 12px;
}
.user-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.user-result-item:hover {
    background: var(--bg-hover);
}
.user-result-info {
    flex: 1;
}
.user-result-name {
    font-weight: 600;
    font-size: 15px;
}
.user-result-username {
    font-size: 13px;
    color: var(--text-secondary);
}

/* === Chat Area === */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
    height: 100%;
    min-width: 0;
    position: relative;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}
.empty-icon {
    width: 120px;
    height: 120px;
    margin-bottom: 24px;
}
.empty-icon svg { width: 100%; height: 100%; }
.empty-state h3 {
    font-size: 22px;
    margin-bottom: 8px;
}
.empty-state p {
    color: var(--text-secondary);
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    height: var(--header-height);
    z-index: 10;
    gap: 8px;
    flex-shrink: 0;
}
.back-btn {
    display: none;
}
.chat-header-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    cursor: pointer;
}
.chat-header-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.chat-header-name {
    font-weight: 600;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-header-status {
    font-size: 13px;
    color: var(--text-secondary);
}
.chat-header-status.online {
    color: var(--success);
}
.chat-header-actions {
    display: flex;
    gap: 4px;
}

/* Messages */
.messages-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    min-height: 0;
}
.messages-container {
    width: 100%;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 100%;
    justify-content: flex-end;
}

.message {
    display: flex;
    margin: 2px 0;
    max-width: 65%;
    animation: msgIn 0.15s ease;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-incoming {
    align-self: flex-start;
    margin-right: auto;
}
.message-outgoing {
    align-self: flex-end;
    margin-left: auto;
}

.message-bubble {
    padding: 8px 12px;
    border-radius: var(--radius-lg);
    max-width: 100%;
    word-wrap: break-word;
    position: relative;
    line-height: 1.45;
}
.message-incoming .message-bubble {
    background: var(--bg-message-in);
    border-bottom-left-radius: 4px;
}
.message-outgoing .message-bubble {
    background: var(--bg-message-out);
    border-bottom-right-radius: 4px;
}

.message-sender {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: 2px;
}
.message-text {
    font-size: 15px;
    white-space: pre-wrap;
    word-break: break-word;
}
.message-text a {
    color: var(--primary-light);
    text-decoration: underline;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 2px;
}
.message-time {
    font-size: 11px;
    color: var(--text-muted);
}
.message-edited {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

.message-image {
    max-width: 320px;
    border-radius: var(--radius-sm);
    margin: 4px 0;
    cursor: pointer;
}
.message-image img {
    width: 100%;
    border-radius: var(--radius-sm);
    display: block;
}

.message-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.15);
    border-radius: var(--radius-sm);
    margin: 4px 0;
    cursor: pointer;
    transition: var(--transition);
}
.message-file:hover {
    background: rgba(0,0,0,0.25);
}
.message-file-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.message-file-icon svg {
    width: 20px;
    height: 20px;
    color: white;
}
.message-file-info {
    flex: 1;
    min-width: 0;
}
.message-file-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.message-file-size {
    font-size: 12px;
    color: var(--text-muted);
}

.message-reply {
    padding: 6px 10px;
    background: rgba(108, 99, 255, 0.1);
    border-left: 3px solid var(--primary);
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 13px;
    cursor: pointer;
}
.message-reply-name {
    font-weight: 600;
    color: var(--primary-light);
    font-size: 12px;
}
.message-reply-text {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-deleted {
    font-style: italic;
    color: var(--text-muted);
    font-size: 14px;
}

.date-separator {
    text-align: center;
    padding: 12px 0;
}
.date-separator span {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

/* Message context menu */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 2000;
    min-width: 180px;
    overflow: hidden;
    animation: modalIn 0.15s ease;
}
.context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
    font-size: 14px;
}
.context-menu-item:hover {
    background: var(--bg-hover);
}
.context-menu-item svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}
.context-menu-item.danger { color: var(--danger); }
.context-menu-item.danger svg { color: var(--danger); }

/* Typing indicator */
.typing-indicator {
    padding: 4px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--primary-light);
    flex-shrink: 0;
}
.typing-dots {
    display: flex;
    gap: 3px;
}
.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Reply preview */
.reply-preview {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    gap: 12px;
    flex-shrink: 0;
}
.reply-preview-content {
    flex: 1;
    min-width: 0;
    border-left: 3px solid var(--primary);
    padding-left: 10px;
}
.reply-preview-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-light);
}
.reply-preview-text {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Message input */
.message-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}
.message-input-wrapper {
    flex: 1;
    position: relative;
}
.message-input-wrapper textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    font-family: inherit;
    transition: var(--transition);
}
.message-input-wrapper textarea:focus {
    border-color: var(--primary);
}
.message-input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

/* === AI Assistant Button === */
.ai-btn {
    color: var(--text-muted) !important;
    padding: 10px !important;
    transition: var(--transition);
}
.ai-btn:hover {
    color: var(--primary) !important;
    background: rgba(108, 99, 255, 0.12) !important;
}
.ai-btn.ai-loading {
    color: var(--primary) !important;
    animation: aiPulse 1s ease-in-out infinite;
    pointer-events: none;
}
@keyframes aiPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* === AI Menu Popup === */
.ai-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 6px;
    min-width: 240px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    z-index: 100;
    animation: aiMenuIn 0.15s ease-out;
}
@keyframes aiMenuIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.ai-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
}
.ai-menu-item:hover {
    background: rgba(108, 99, 255, 0.12);
}
.ai-menu-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: var(--primary);
}
.ai-menu-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ai-menu-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.ai-menu-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.3;
}

/* === AI Error Toast === */
.ai-error-toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger);
    color: #fff;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(255, 71, 87, 0.4);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

.send-btn {
    color: var(--primary) !important;
    padding: 10px !important;
}
.send-btn:hover {
    background: rgba(108, 99, 255, 0.15) !important;
}

/* === Voice Button === */
.voice-btn {
    color: var(--text-secondary) !important;
    padding: 10px !important;
}
.voice-btn:hover {
    color: var(--danger) !important;
    background: rgba(255, 71, 87, 0.15) !important;
}

/* === Voice Recording Overlay === */
.voice-recording-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    z-index: 50;
    flex-shrink: 0;
    animation: slideUp 0.2s ease;
}
.voice-recording-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 500px;
}
.voice-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 30px;
}
.voice-wave span {
    width: 4px;
    background: var(--danger);
    border-radius: 2px;
    animation: voiceWave 1s ease-in-out infinite;
}
.voice-wave span:nth-child(1) { height: 10px; animation-delay: 0s; }
.voice-wave span:nth-child(2) { height: 20px; animation-delay: 0.1s; }
.voice-wave span:nth-child(3) { height: 28px; animation-delay: 0.2s; }
.voice-wave span:nth-child(4) { height: 18px; animation-delay: 0.3s; }
.voice-wave span:nth-child(5) { height: 12px; animation-delay: 0.4s; }
@keyframes voiceWave {
    0%, 100% { transform: scaleY(0.4); }
    50% { transform: scaleY(1); }
}
.voice-timer {
    font-size: 18px;
    font-weight: 600;
    color: var(--danger);
    min-width: 50px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.voice-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}
.voice-cancel-btn {
    color: var(--text-muted) !important;
}
.voice-cancel-btn:hover {
    color: var(--danger) !important;
    background: rgba(255, 71, 87, 0.15) !important;
}
.voice-send-btn {
    color: var(--primary) !important;
}
.voice-send-btn:hover {
    background: rgba(108, 99, 255, 0.15) !important;
}

/* === Voice Message Player === */
.voice-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    min-width: 200px;
}
.voice-play-btn {
    background: var(--primary);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}
.voice-play-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}
.voice-play-btn svg {
    width: 16px;
    height: 16px;
}
.voice-waveform-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.voice-progress-bar {
    height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
}
[data-theme="light"] .voice-progress-bar {
    background: rgba(0,0,0,0.1);
}
.voice-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s linear;
}
.voice-duration {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Voice STT (speech-to-text) button */
.voice-stt-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
    padding: 0;
}
.voice-stt-btn svg {
    width: 16px;
    height: 16px;
}
.voice-stt-btn:hover {
    color: var(--primary);
    background: var(--bg-hover);
}
.voice-stt-btn.active {
    color: var(--danger);
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Voice transcript */
.voice-transcript {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 0 2px;
    font-style: italic;
    line-height: 1.4;
    margin-top: 4px;
}

/* === User Profile Modal === */
.profile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px 8px;
}
.profile-avatar-wrapper {
    position: relative;
    margin-bottom: 16px;
}
.profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 38px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
.profile-online-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4caf50;
    border: 3px solid var(--bg-primary);
    display: none;
}
.profile-online-badge.visible {
    display: block;
}
.profile-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
    text-align: center;
}
.profile-username {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.profile-status-text {
    font-size: 13px;
    color: var(--primary);
    margin-bottom: 16px;
}
.profile-info-list {
    width: 100%;
    list-style: none;
    padding: 0;
    margin: 0;
}
.profile-info-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}
.profile-info-item:last-child {
    border-bottom: none;
}
.profile-info-icon {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.profile-info-icon svg {
    width: 20px;
    height: 20px;
}
.profile-info-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.profile-info-value {
    font-size: 15px;
    color: var(--text-primary);
    word-break: break-word;
}
.profile-info-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}
.profile-encryption {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin: 12px 16px 16px;
}
.profile-encryption svg {
    width: 20px;
    height: 20px;
    color: #4caf50;
    flex-shrink: 0;
}
.profile-encryption span {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* === Toast Notifications === */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 380px;
    width: calc(100% - 32px);
}
.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25), 0 2px 8px rgba(0,0,0,0.12);
    border: 1px solid var(--border-color);
    pointer-events: auto;
    cursor: pointer;
    animation: toastSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    transition: opacity 0.3s, transform 0.3s;
    overflow: hidden;
}
.toast.removing {
    opacity: 0;
    transform: translateX(100%);
}
@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}
.toast-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.toast-body {
    flex: 1;
    min-width: 0;
}
.toast-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}
.toast-sender {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toast-app {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.toast-text {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}
.toast:hover .toast-close {
    opacity: 1;
}
.toast-close svg {
    width: 16px;
    height: 16px;
}
.toast-type-call .toast-avatar {
    background: #4caf50;
}
.toast-type-call .toast-text {
    color: #4caf50;
}

/* === Audio Calls === */
.call-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(12px);
    animation: callFadeIn 0.3s ease;
}
@keyframes callFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.call-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 40px 40px;
    min-width: 320px;
    max-width: 400px;
    border-radius: 24px;
    background: var(--bg-primary);
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.call-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 38px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 24px rgba(108,92,231,0.4);
}
.call-avatar-active {
    animation: callAvatarPulse 2s ease-in-out infinite;
}
@keyframes callAvatarPulse {
    0%, 100% { box-shadow: 0 4px 24px rgba(108,92,231,0.4); }
    50% { box-shadow: 0 4px 40px rgba(108,92,231,0.7); }
}
.call-caller-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    text-align: center;
}
.call-status-text {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}
.call-timer {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}
.call-ringtone-wave, .call-active-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 32px;
    margin-bottom: 32px;
}
.call-ringtone-wave span, .call-active-wave span {
    display: block;
    width: 4px;
    border-radius: 2px;
    background: var(--primary);
    animation: callWave 1.2s ease-in-out infinite;
}
.call-ringtone-wave span:nth-child(1) { height: 8px; animation-delay: 0s; }
.call-ringtone-wave span:nth-child(2) { height: 16px; animation-delay: 0.1s; }
.call-ringtone-wave span:nth-child(3) { height: 24px; animation-delay: 0.2s; }
.call-ringtone-wave span:nth-child(4) { height: 16px; animation-delay: 0.3s; }
.call-ringtone-wave span:nth-child(5) { height: 8px; animation-delay: 0.4s; }
.call-active-wave span:nth-child(1) { height: 6px; animation-delay: 0s; }
.call-active-wave span:nth-child(2) { height: 12px; animation-delay: 0.08s; }
.call-active-wave span:nth-child(3) { height: 20px; animation-delay: 0.16s; }
.call-active-wave span:nth-child(4) { height: 28px; animation-delay: 0.24s; }
.call-active-wave span:nth-child(5) { height: 20px; animation-delay: 0.32s; }
.call-active-wave span:nth-child(6) { height: 12px; animation-delay: 0.4s; }
.call-active-wave span:nth-child(7) { height: 6px; animation-delay: 0.48s; }
@keyframes callWave {
    0%, 100% { transform: scaleY(0.4); opacity: 0.5; }
    50% { transform: scaleY(1); opacity: 1; }
}
.call-actions {
    display: flex;
    align-items: center;
    gap: 32px;
}
.call-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.call-btn svg {
    width: 28px;
    height: 28px;
}
.call-btn:hover {
    transform: scale(1.08);
}
.call-btn-accept {
    background: #4caf50;
    color: #fff;
    box-shadow: 0 4px 20px rgba(76,175,80,0.4);
    animation: callBtnRing 1.5s ease-in-out infinite;
}
@keyframes callBtnRing {
    0%, 100% { box-shadow: 0 4px 20px rgba(76,175,80,0.4); }
    50% { box-shadow: 0 4px 32px rgba(76,175,80,0.7); }
}
.call-btn-reject, .call-btn-end {
    background: #f44336;
    color: #fff;
    box-shadow: 0 4px 20px rgba(244,67,54,0.4);
}
.call-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.15s;
    padding: 8px;
}
.call-action-btn svg {
    width: 28px;
    height: 28px;
    padding: 12px;
    border-radius: 50%;
    background: var(--bg-secondary);
    box-sizing: content-box;
    transition: background 0.15s;
}
.call-action-btn span {
    font-size: 11px;
}
.call-action-btn:hover {
    color: var(--primary);
}
.call-action-btn:hover svg {
    background: var(--bg-hover);
}
.call-action-btn.active svg {
    background: var(--primary);
    color: #fff;
}
.call-action-btn.active {
    color: var(--primary);
}
.call-connecting {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
    animation: callDots 1.5s infinite;
}
@keyframes callDots {
    0% { content: ''; }
    33% { content: '.'; }
    66% { content: '..'; }
    100% { content: '...'; }
}

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 100;
        transition: transform 0.25s ease;
    }
    .sidebar.hidden {
        transform: translateX(-100%);
    }

    .chat-area {
        position: absolute;
        inset: 0;
        z-index: 50;
        transform: translateX(100%);
        transition: transform 0.25s ease;
    }
    .chat-area.active {
        transform: translateX(0);
        z-index: 200;
    }

    .back-btn {
        display: flex;
    }

    .modal-panel {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
}

@media (min-width: 769px) {
    .sidebar {
        position: relative;
    }
    .chat-area {
        position: relative;
        transform: none;
    }
}

/* === PWA Install Banner === */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-top: 2px solid var(--accent-color);
    padding: 16px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 3000;
    box-shadow: 0 -4px 20px rgba(108, 99, 255, 0.3);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.install-banner-visible {
    transform: translateY(0);
}
.install-banner-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.4);
}
.install-banner-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.install-banner-text {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.3;
}
.install-banner-text strong {
    display: block;
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.install-banner-text span {
    display: block;
}
.install-btn {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 24px;
    background: var(--accent-color);
    color: #fff;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
}
.install-btn:active {
    transform: scale(0.95);
}
.install-dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    font-size: 18px;
    line-height: 1;
}

/* ==================== GROUP STYLES ==================== */

/* Group avatar in chat list & header */
.avatar-group {
    background: linear-gradient(135deg, var(--accent-color), #9b59b6) !important;
}
.avatar-group-icon {
    width: 24px;
    height: 24px;
    color: #fff;
}
.avatar.avatar-group {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Group Create Form */
.group-create-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.group-create-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 0;
}
.group-avatar-placeholder {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-color), #9b59b6);
}
.group-avatar-placeholder svg {
    width: 32px;
    height: 32px;
    color: #fff;
}
.group-name-input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}
.group-name-input:focus {
    border-color: var(--accent-color);
}
.group-name-input::placeholder {
    color: var(--text-muted);
}

/* Selected member chips */
.group-members-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.group-members-section h4 {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
}
.selected-members {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 0;
}
.member-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--accent-color);
    color: #fff;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 13px;
    animation: chipIn 0.2s ease;
}
@keyframes chipIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.member-chip-remove {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
}
.member-chip-remove:hover {
    color: #fff;
}

/* User result add button */
.user-result-add {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-color);
    color: #fff;
    border-radius: 50%;
    font-size: 18px;
    font-weight: 600;
    flex-shrink: 0;
    margin-left: auto;
}

/* Group Info Card */
.group-info-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    gap: 8px;
}
.group-info-avatar .avatar {
    width: 80px;
    height: 80px;
    font-size: 32px;
}
.group-info-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}
.group-info-desc {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    max-width: 300px;
}
.group-info-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* Group Edit Section */
.group-edit-section {
    padding: 12px 0;
    border-top: 1px solid var(--border-color);
}
.group-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.group-edit-actions .btn {
    flex: 1;
}

/* Group Invite Link */
.group-invite-section {
    padding: 12px 0;
    border-top: 1px solid var(--border-color);
}
.group-invite-section h4 {
    margin: 0 0 8px;
    font-size: 14px;
    color: var(--text-secondary);
}
.group-invite-link-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.group-invite-input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

/* Group Members List */
.group-members-list-section {
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}
.group-members-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.group-members-header h4 {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
}
.group-members-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 300px;
    overflow-y: auto;
}
.group-member-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 10px;
    transition: background 0.15s;
}
.group-member-item:hover {
    background: var(--bg-secondary);
}
.group-member-info {
    flex: 1;
    min-width: 0;
}
.group-member-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.group-member-role {
    font-size: 12px;
    color: var(--text-muted);
}
.group-member-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}
.group-member-item:hover .group-member-actions {
    opacity: 1;
}
.icon-btn-sm {
    width: 28px;
    height: 28px;
    padding: 4px;
}
.icon-btn-danger {
    color: var(--danger) !important;
}
.icon-btn-danger:hover {
    background: rgba(239, 68, 68, 0.15) !important;
}

/* Group Add Member */
.group-add-member-section {
    padding-top: 8px;
}

/* System message */
.system-message {
    display: flex;
    justify-content: center;
    padding: 4px 0;
}
.system-message span {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 12px;
}

/* Button variants */
.btn-sm {
    padding: 4px 12px;
    font-size: 13px;
}
.btn-text {
    background: none;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    font-weight: 600;
}
.btn-text:hover {
    opacity: 0.8;
}
.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-danger {
    background: var(--danger);
    color: #fff;
    border: none;
}
.btn-danger:hover {
    opacity: 0.9;
}

.text-muted {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 12px;
}

/* Mobile group member actions always visible */
@media (max-width: 768px) {
    .group-member-actions {
        opacity: 1;
    }
}
