/* Modern Chat App - Complete CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --primary: #4361ee;
    --primary-dark: #3a0ca3;
    --primary-light: #4895ef;
    --secondary: #7209b7;
    --secondary-dark: #5a078f;
    --accent: #f72585;

    /* Status Colors */
    --success: #4cc9f0;
    --success-dark: #2aa6c7;
    --warning: #ff9e00;
    --error: #f72585;
    --info: #4361ee;

    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --bg-dark: #212529;

    /* Text Colors */
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-light: #adb5bd;
    --text-inverse: #ffffff;

    /* Border Colors */
    --border-light: #dee2e6;
    --border-medium: #ced4da;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px rgba(0, 0, 0, 0.15);

    /* Border Radius */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 999px;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.login-card {
    width: min(420px, 92vw);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-lg);
}

.login-card h2 {
    font-size: 22px;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.login-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.login-card label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-card input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    margin-bottom: var(--space-md);
    font-size: 14px;
    outline: none;
}

.login-card input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.btn-login {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: none;
    background: var(--primary);
    color: var(--text-inverse);
    font-size: 15px;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

.btn-login:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.login-error {
    margin-top: var(--space-sm);
    background: rgba(247, 37, 133, 0.12);
    color: var(--error);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    z-index: 10;
    flex-shrink: 0;
}

.sidebar-header {
    padding: var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo i {
    font-size: 24px;
    color: var(--primary);
}

.logo h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-new-chat {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: var(--text-inverse);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-new-chat:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* User Profile */
.user-profile {
    padding: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    border-bottom: 1px solid var(--border-light);
}

.avatar {
    position: relative;
    width: 44px;
    height: 44px;
    cursor: pointer;
}

.avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    object-fit: cover;
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-secondary);
}

.status-indicator.online {
    background: var(--success);
}

.status-indicator.away {
    background: var(--warning);
}

.status-indicator.busy {
    background: var(--error);
}

.status-indicator.offline {
    background: var(--text-light);
}

.user-info {
    flex: 1;
}

.user-info h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.user-info p {
    font-size: 12px;
    color: var(--text-secondary);
}

.btn-settings {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.btn-settings:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Search Bar */
.search-bar {
    padding: var(--space-md);
    position: relative;
}

.search-bar i {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 16px;
}

.search-bar input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    font-size: 14px;
    transition: all 0.2s ease;
    outline: none;
}

.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

/* Conversations */
.conversations {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
}

.conversation-item {
    padding: var(--space-sm);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 2px;
}

.conversation-item:hover {
    background: var(--bg-tertiary);
}

.conversation-item.active {
    background: var(--primary);
    color: var(--text-inverse);
}

.conversation-avatar {
    position: relative;
    width: 40px;
    height: 40px;
}

.conversation-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    object-fit: cover;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-preview {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.conversation-time {
    font-size: 11px;
    color: var(--text-light);
}

.conversation-badge {
    background: var(--primary);
    color: var(--text-inverse);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
}

/* Sidebar Footer */
.sidebar-footer {
    display: flex;
    justify-content: space-around;
    padding: var(--space-md);
    border-top: 1px solid var(--border-light);
}

.sidebar-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    border: none;
    background: none;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.sidebar-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-btn.active {
    background: var(--primary);
    color: var(--text-inverse);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
    min-height: 0; /* Crucial fix for flex children */
}

/* Chat Header */
.chat-header {
    padding: var(--space-md) var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.chat-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.chat-avatar {
    width: 44px;
    height: 44px;
    cursor: pointer;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    object-fit: cover;
}

.chat-avatar:hover {
    transform: scale(1.03);
}

.chat-details h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.chat-details p {
    font-size: 14px;
    color: var(--text-secondary);
}

.chat-actions {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.ice-server-select {
    height: 36px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0 12px;
    font-size: 12px;
    outline: none;
}

.ice-server-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.12);
}

.action-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.action-btn.call-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--text-inverse);
    box-shadow: var(--shadow-sm);
}

.action-btn.call-btn:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-dark) 100%);
    color: var(--text-inverse);
    transform: translateY(-1px);
}

.action-btn.disabled,
.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    min-height: 0; /* Crucial fix for scrolling */
}

.date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: var(--space-md) 0;
}

.date-separator span {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 12px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
}

/* Message Styles */
.message {
    display: flex;
    animation: messageSlideIn 0.3s ease-out;
    max-width: 80%;
}

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

.message.received {
    align-self: flex-start;
}

.message.sent {
    align-self: flex-end;
}

.system-message {
    align-self: center;
    max-width: 100%;
}

.system-message-bubble {
    background: rgba(17, 24, 39, 0.08);
    color: var(--text-secondary);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
}

.message-content {
    position: relative;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    position: relative;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
}

.received .message-bubble {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: var(--radius-sm);
}

.sent .message-bubble {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--text-inverse);
    border-bottom-right-radius: var(--radius-sm);
}

.message-text {
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 4px;
}

.message-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-sm);
    font-size: 12px;
    opacity: 0.8;
}

.message-time {
    font-size: 11px;
}

.message-edited {
    font-size: 11px;
    opacity: 0.75;
}

.message-status {
    display: flex;
    align-items: center;
}

.message-status.sending {
    color: var(--text-light);
}

.message-status.read {
    color: var(--success);
}

.message-text.deleted {
    font-style: italic;
    color: var(--text-secondary);
    opacity: 0.95;
}

.message-reply-context {
    border-left: 3px solid rgba(67, 97, 238, 0.85);
    background: rgba(67, 97, 238, 0.08);
    border-radius: 10px;
    padding: 6px 10px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sent .message-reply-context {
    border-left-color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.18);
}

.message-reply-context .reply-author {
    font-size: 12px;
    font-weight: 600;
}

.message-reply-context .reply-snippet {
    font-size: 12px;
    opacity: 0.9;
    word-break: break-word;
}

/* Typing Indicator */
.typing-indicator {
    padding: 0 var(--space-lg) var(--space-md);
    display: none;
    align-items: center;
    gap: var(--space-sm);
}

.typing-dots {
    display: flex;
    gap: var(--space-xs);
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--text-light);
    animation: typingDot 1.5s 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 typingDot {
    0%, 100% { opacity: 0.3; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-2px); }
}

.typing-indicator p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Message Input Container */
.message-input-container {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-light);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.input-actions {
    display: flex;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.message-input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.input-with-send {
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-xs);
    transition: all 0.2s ease;
}

.input-with-send:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.input-area {
    flex: 1;
    min-height: 24px;
    max-height: 120px;
    overflow-y: auto;
    padding: var(--space-sm);
    background: transparent;
    font-size: 15px;
    line-height: 1.5;
    outline: none;
    border: none;
}

.input-area[placeholder]:empty:before {
    content: attr(placeholder);
    color: var(--text-light);
}

.reply-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: 10px 12px;
    border-radius: var(--radius);
    background: rgba(67, 97, 238, 0.08);
    border-left: 4px solid var(--primary);
}

.reply-preview .reply-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.reply-preview .reply-user {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-dark);
}

.reply-preview .reply-text {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.cancel-reply {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.cancel-reply:hover {
    background: rgba(0, 0, 0, 0.16);
}

.btn-send {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--text-inverse);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.btn-send:disabled {
    background: var(--text-light);
    cursor: not-allowed;
    transform: none;
}

/* File Preview */
.file-preview {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.preview-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--space-md);
}

.preview-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    min-height: 150px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.preview-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.preview-thumb {
    position: relative;
    height: 110px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-thumb img,
.preview-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-thumb.image-thumb {
    background: linear-gradient(180deg, rgba(67, 97, 238, 0.1), rgba(114, 9, 183, 0.08));
}

.preview-thumb.video-thumb {
    background: linear-gradient(180deg, rgba(72, 149, 239, 0.12), rgba(67, 97, 238, 0.08));
}

.preview-thumb.file-thumb {
    background: linear-gradient(180deg, rgba(33, 37, 41, 0.08), rgba(33, 37, 41, 0.02));
}

.preview-thumb .file-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-full);
    background: rgba(67, 97, 238, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 22px;
}

.preview-badge {
    position: absolute;
    left: 8px;
    top: 8px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(33, 37, 41, 0.7);
    color: var(--text-inverse);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    letter-spacing: 0.4px;
}

.preview-type-icon {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-full);
    background: rgba(17, 24, 39, 0.7);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.preview-remove {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    border: none;
    background: rgba(0, 0, 0, 0.55);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

.preview-remove:hover {
    transform: scale(1.05);
    background: rgba(0, 0, 0, 0.7);
}

.preview-meta {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preview-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-type {
    font-size: 11px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-size {
    font-size: 12px;
    color: var(--text-secondary);
}

/* File preview inside chat messages */
.message .file-message.preview-item {
    min-height: auto;
    width: 100%;
    max-width: 340px;
}

.message.sent .file-message.preview-item {
    border-color: rgba(255, 255, 255, 0.2);
}

.message.sent .file-message.preview-item .preview-thumb.file-thumb {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.05));
}

.message .file-message.preview-item .file-download {
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
}

.message.sent .file-message.preview-item .file-download {
    color: var(--text-inverse);
    opacity: 0.9;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.preview-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.clear-all {
    background: none;
    border: none;
    color: var(--error);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.clear-all:hover {
    background: rgba(247, 37, 133, 0.1);
}

/* Emoji + Sticker Picker */
.emoji-picker {
    position: absolute;
    right: 24px;
    bottom: 90px;
    width: 320px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-md);
    z-index: 1200;
}

.emoji-tabs {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.emoji-tab {
    flex: 1;
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.emoji-tab.active {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: transparent;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
}

.emoji {
    font-size: 20px;
    text-align: center;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius);
    transition: background 0.2s ease;
}

.emoji:hover {
    background: var(--bg-secondary);
}

.sticker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
}

.sticker-item {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sticker-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.sticker-item img {
    width: 72px;
    height: 72px;
    object-fit: contain;
}

.sticker-message {
    max-width: 180px;
    max-height: 180px;
    padding: 6px;
    border-radius: var(--radius-lg);
    background: rgba(0, 0, 0, 0.04);
}

.message.sent .sticker-message {
    background: rgba(255, 255, 255, 0.16);
}

.sticker-message img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Voice Recorder */
/* Voice Recorder Styling */
.voice-recorder {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary-dark) 100%);
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-md);
    color: var(--text-inverse);
}

.recorder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.recorder-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-inverse);
    margin: 0;
}

.recording-time {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-inverse);
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 12px;
    border-radius: var(--radius-full);
}

.recorder-visualizer {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    height: 60px;
    gap: 4px;
    margin: var(--space-md) 0;
}

.visualizer-bar {
    width: 6px;
    background: var(--text-inverse);
    border-radius: var(--radius-full);
    animation: visualizerWave 1s infinite ease-in-out;
}

.visualizer-bar:nth-child(1) { animation-delay: 0s; height: 20px; }
.visualizer-bar:nth-child(2) { animation-delay: 0.1s; height: 30px; }
.visualizer-bar:nth-child(3) { animation-delay: 0.2s; height: 40px; }
.visualizer-bar:nth-child(4) { animation-delay: 0.3s; height: 30px; }
.visualizer-bar:nth-child(5) { animation-delay: 0.4s; height: 20px; }

@keyframes visualizerWave {
    0%, 100% { transform: scaleY(0.7); opacity: 0.7; }
    50% { transform: scaleY(1); opacity: 1; }
}

.recorder-controls {
    display: flex;
    justify-content: center;
    gap: var(--space-xl);
    margin-top: var(--space-lg);
}

.voice-preview {
    margin-top: var(--space-md);
    background: rgba(255, 255, 255, 0.12);
    padding: 10px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.voice-preview audio {
    width: 100%;
    display: block;
}

.voice-preview-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 90px;
    align-items: center;
    color: var(--text-inverse);
}

.voice-preview-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 26px;
}

.voice-preview-wave span {
    width: 3px;
    height: 8px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: var(--radius-full);
    animation: previewWave 1.2s ease-in-out infinite;
    animation-play-state: paused;
}

.voice-preview-wave span:nth-child(2) { animation-delay: 0.1s; height: 12px; }
.voice-preview-wave span:nth-child(3) { animation-delay: 0.2s; height: 18px; }
.voice-preview-wave span:nth-child(4) { animation-delay: 0.3s; height: 10px; }
.voice-preview-wave span:nth-child(5) { animation-delay: 0.4s; height: 16px; }
.voice-preview-wave span:nth-child(6) { animation-delay: 0.5s; height: 12px; }
.voice-preview-wave span:nth-child(7) { animation-delay: 0.6s; height: 20px; }
.voice-preview-wave span:nth-child(8) { animation-delay: 0.7s; height: 10px; }
.voice-preview-wave span:nth-child(9) { animation-delay: 0.8s; height: 14px; }
.voice-preview-wave span:nth-child(10){ animation-delay: 0.9s; height: 8px; }

.voice-preview.playing .voice-preview-wave span {
    animation-play-state: running;
}

.voice-preview-duration {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    opacity: 0.9;
}

.voice-preview-stop {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-inverse);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
}

.voice-preview-stop:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.35);
}

.btn-cancel, .btn-send-recording {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 20px;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-inverse);
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.btn-send-recording {
    background: var(--success);
    color: var(--text-inverse);
}

.btn-send-recording:hover {
    background: var(--success-dark);
    transform: scale(1.1);
}

/* Voice Message Styling */
.voice-message {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 200px;
    max-width: 300px;
}

.voice-message:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.voice-play-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--text-inverse);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--primary);
    font-size: 16px;
}

.voice-play-btn:hover {
    transform: scale(1.1);
    background: var(--bg-secondary);
}

.voice-waveform {
    flex: 1;
    height: 40px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.voice-waveform span {
    width: 3px;
    height: 8px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: var(--radius-full);
    animation: voiceWave 1.2s ease-in-out infinite;
    animation-play-state: paused;
}

.voice-waveform span:nth-child(2) { animation-delay: 0.1s; height: 12px; }
.voice-waveform span:nth-child(3) { animation-delay: 0.2s; height: 18px; }
.voice-waveform span:nth-child(4) { animation-delay: 0.3s; height: 10px; }
.voice-waveform span:nth-child(5) { animation-delay: 0.4s; height: 16px; }
.voice-waveform span:nth-child(6) { animation-delay: 0.5s; height: 12px; }
.voice-waveform span:nth-child(7) { animation-delay: 0.6s; height: 20px; }
.voice-waveform span:nth-child(8) { animation-delay: 0.7s; height: 10px; }
.voice-waveform span:nth-child(9) { animation-delay: 0.8s; height: 14px; }
.voice-waveform span:nth-child(10){ animation-delay: 0.9s; height: 8px; }

.voice-message.playing .voice-waveform span {
    animation-play-state: running;
}

@keyframes voiceWave {
    0%, 100% { transform: scaleY(0.7); opacity: 0.7; }
    50% { transform: scaleY(1); opacity: 1; }
}

.voice-duration {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-inverse);
    min-width: 40px;
    text-align: right;
}

/* Playing state */
.voice-message.playing .voice-play-btn {
    background: var(--text-inverse);
}

.voice-message.playing .voice-play-btn i {
    content: '\f28b'; /* pause icon */
}

/* Audio player styling */
audio {
    display: none; /* Hide default audio player */
}

/* Voice recording button states */
.voice-btn.recording {
    background: var(--error) !important;
    color: var(--text-inverse) !important;
}

.voice-btn.recording i {
    animation: pulse 1s infinite;
}

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

/* Microphone permission request styling */
.permission-request {
    background: var(--warning);
    color: var(--text-inverse);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius);
    margin-top: var(--space-sm);
    font-size: 14px;
    text-align: center;
    animation: slideIn 0.3s ease;
}

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

/* Right Sidebar */
.right-sidebar {
    width: 320px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-light);
    padding: var(--space-lg);
    overflow-y: auto;
    display: none;
    flex-shrink: 0;
}

/* Media Queries - FIXED RESPONSIVE DESIGN */

/* Tablet View */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        transition: width 0.3s ease;
    }

    .sidebar:hover {
        width: 280px;
    }

    .sidebar:hover .logo h1,
    .sidebar:hover .user-info,
    .sidebar:hover .search-bar input,
    .sidebar:hover .conversation-info,
    .sidebar:hover .conversation-meta {
        display: block;
    }

    .logo h1,
    .user-info,
    .search-bar input,
    .conversation-info,
    .conversation-meta {
        display: none;
    }

    .logo {
        justify-content: center;
    }

    .user-profile {
        justify-content: center;
        padding: var(--space-sm);
    }

    .search-bar {
        padding: var(--space-sm);
    }

    .search-bar i {
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .right-sidebar {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        max-width: 320px;
        z-index: 1000;
        box-shadow: var(--shadow-lg);
    }

    .app-container {
        position: relative;
    }
}

/* Mobile View - CRITICAL FIXES */
@media (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
    }

    .app-container {
        flex-direction: column;
        height: 100vh;
        min-height: 100vh;
        overflow: hidden;
    }

    /* Mobile Sidebar (Top Navigation) */
    .sidebar {
        width: 100%;
        height: 60px;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        padding: 0 var(--space-md);
        justify-content: space-between;
        align-items: center;
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .sidebar-header {
        padding: 0;
        border-bottom: none;
        width: auto;
    }

    .logo h1 {
        display: block;
        font-size: 18px;
    }

    .user-profile,
    .search-bar,
    .conversations {
        display: none;
    }

    .sidebar-footer {
        padding: 0;
        border-top: none;
        margin: 0;
    }

    .sidebar-btn {
        width: 44px;
        height: 44px;
    }

    /* Main Content - Mobile Fixes */
    .main-content {
        height: calc(100vh - 60px); /* Subtract sidebar height */
        min-height: 0;
    }

    .chat-header {
        padding: var(--space-sm) var(--space-md);
        position: sticky;
        top: 60px;
        z-index: 90;
        background: var(--bg-primary);
    }

    .messages-container {
        padding: var(--space-md);
        height: calc(100% - 60px - 56px); /* Subtract header and input height */
        overflow-y: auto;
    }

    .message {
        max-width: 90%;
    }

.message-input-container {
        padding: var(--space-sm) var(--space-md);
        position: sticky;
        bottom: 0;
        background: var(--bg-primary);
        border-top: 1px solid var(--border-light);
        z-index: 80;
    }

    .input-row {
        margin-bottom: var(--space-sm);
        gap: var(--space-sm);
    }

    .input-actions {
        gap: 4px;
    }

    .action-btn {
        width: 36px;
        height: 36px;
    }

    .input-with-send {
        border-radius: var(--radius-md);
    }

    .btn-send {
        width: 36px;
        height: 36px;
    }

    /* Adjust chat header for mobile */
    .chat-details h2 {
        font-size: 16px;
    }

    .chat-actions {
        gap: 4px;
    }

    .ice-server-select {
        max-width: 126px;
        padding: 0 8px;
        font-size: 11px;
    }

    .emoji-picker {
        width: calc(100% - 20px);
        left: 10px;
        right: 10px;
        bottom: 70px;
    }
}

.message-actions-menu {
    position: fixed;
    z-index: 1300;
    min-width: 170px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
}

.message-actions-menu .action-item {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.message-actions-menu .action-item:hover {
    background: var(--bg-secondary);
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    .sidebar {
        height: 56px;
        padding: 0 var(--space-sm);
    }

    .logo h1 {
        font-size: 16px;
    }

    .sidebar-btn {
        width: 40px;
        height: 40px;
    }

    .main-content {
        height: calc(100vh - 56px);
    }

    .chat-header {
        top: 56px;
        padding: 10px var(--space-sm);
    }

    .chat-avatar {
        width: 36px;
        height: 36px;
    }

    .chat-details h2 {
        font-size: 15px;
    }

    .chat-details p {
        font-size: 12px;
    }

    .action-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .ice-server-select {
        display: none;
    }

    .messages-container {
        padding: var(--space-sm);
        height: calc(100% - 56px - 52px);
    }

    .message {
        max-width: 95%;
    }

    .message-bubble {
        padding: 10px 12px;
    }

    .message-text {
        font-size: 14px;
    }

    .message-input-container {
        padding: 10px var(--space-sm);
    }

    .input-area {
        font-size: 14px;
        padding: 8px;
    }

    .btn-send {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .file-preview,
    .voice-recorder {
        padding: var(--space-sm);
    }

    .preview-items {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .right-sidebar {
        width: 100%;
        max-width: none;
        padding: var(--space-md);
    }
}

/* Landscape Mode */
@media (max-height: 600px) and (orientation: landscape) {
    .sidebar {
        width: 60px;
        height: 100vh;
        flex-direction: column;
    }

    .main-content {
        height: 100vh;
    }

    .messages-container {
        height: calc(100vh - 50px - 40px);
    }

    .message-input-container {
        padding: 5px var(--space-md);
    }

    .input-row {
        margin-bottom: 5px;
    }

    .input-area {
        min-height: 20px;
        max-height: 60px;
    }
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
    .app-container {
        height: -webkit-fill-available;
    }

    .messages-container {
        -webkit-overflow-scrolling: touch;
    }
}

/* Fix for Firefox */
@-moz-document url-prefix() {
    .app-container {
        height: 100%;
    }
}

/* Keyboard visible on mobile */
@media (max-height: 500px) {
    .messages-container {
        height: calc(100vh - 40px - 30px);
    }

    .chat-header {
        padding: 5px var(--space-md);
    }

    .message-input-container {
        padding: 5px var(--space-md);
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.gap-2 {
    gap: var(--space-sm);
}

.text-sm {
    font-size: 14px;
}

.text-xs {
    font-size: 12px;
}

.text-primary {
    color: var(--primary);
}

.text-error {
    color: var(--error);
}

.bg-primary {
    background: var(--primary);
}

.rounded-full {
    border-radius: var(--radius-full);
}

/* Focus States */
button:focus,
input:focus,
textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --border-light: #000000;
        --border-medium: #000000;
    }

    .message-bubble {
        border: 2px solid var(--border-light);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Settings Modal */
.settings-modal {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2100;
}

.settings-card {
    width: min(640px, 92vw);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.settings-header h3 {
    font-size: 20px;
    color: var(--text-primary);
}

.btn-close-settings {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
}

.settings-body label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.settings-body input[type="text"] {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    margin-bottom: var(--space-md);
    font-size: 14px;
}

.settings-toggle {
    margin-top: var(--space-md);
    font-size: 14px;
    color: var(--text-primary);
}

.settings-toggle input {
    margin-right: 8px;
}

.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

.settings-field input[type="color"] {
    width: 100%;
    height: 44px;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    padding: 6px;
    background: var(--bg-secondary);
}

.settings-field input[type="file"] {
    width: 100%;
    font-size: 13px;
    border: 1px dashed var(--border-light);
    padding: 10px;
    border-radius: var(--radius);
    background: var(--bg-secondary);
}

.btn-link {
    margin-top: 6px;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 12px;
    cursor: pointer;
    text-align: left;
}

.settings-image-preview {
    margin-top: var(--space-sm);
    width: 100%;
    height: 140px;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 12px;
    overflow: hidden;
}

.settings-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-image-preview {
    height: 120px;
}

.profile-image-preview img {
    object-fit: cover;
}

.settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}

/* Install PWA */
.install-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: none;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--text-inverse);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    font-size: 14px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.install-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.install-btn.inline {
    padding: 8px 10px;
    font-size: 13px;
}

.a2hs-tip {
    position: fixed;
    right: 18px;
    bottom: 70px;
    z-index: 2300;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 12px;
    box-shadow: var(--shadow-sm);
}

/* Profile image modal */
.profile-image-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.profile-image-card {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-xl);
    max-width: min(520px, 90vw);
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-image-card img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius);
    object-fit: contain;
}

.btn-close-profile-image {
    position: absolute;
    top: 12px;
    right: 12px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    cursor: pointer;
}

.btn-close-profile-image:hover {
    background: var(--bg-secondary);
}

.user-profile-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 51;
}

.user-profile-card {
    position: relative;
    width: min(440px, 92vw);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
}

.btn-close-user-profile {
    position: absolute;
    top: 12px;
    right: 12px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    cursor: pointer;
}

.btn-close-user-profile:hover {
    background: var(--bg-secondary);
}

.user-profile-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

#user-profile-avatar {
    width: 78px;
    height: 78px;
    border-radius: 999px;
    object-fit: cover;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
}

.user-profile-info h3 {
    margin: 0 0 4px 0;
    font-size: 20px;
    color: var(--text-primary);
}

.user-profile-info p {
    margin: 0 0 8px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.user-profile-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.user-profile-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--text-light);
}

.user-profile-status.online::before {
    background: #22c55e;
}
/* Video Recorder Modal */
.video-recorder-modal {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2200;
}

.video-recorder-card {
    width: min(560px, 92vw);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.video-recorder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.video-recorder-header h4 {
    font-size: 16px;
    color: var(--text-primary);
}

#video-preview {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    object-fit: cover;
}

.video-recorder-controls {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
}

.video-control-btn {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.video-control-btn.record {
    background: var(--error);
    color: var(--text-inverse);
}

.video-control-btn.stop {
    background: var(--warning);
    color: var(--text-inverse);
}

.video-control-btn.send {
    background: var(--success);
    color: var(--text-inverse);
}

.video-control-btn.cancel {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.video-control-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Video Call Modal */
.video-call-modal {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2200;
}

.video-call-card {
    width: min(720px, 96vw);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.video-call-header h3 {
    font-size: 18px;
    color: var(--text-primary);
}

.video-call-header p {
    font-size: 13px;
    color: var(--text-secondary);
}

.video-call-streams {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--bg-dark);
    border-radius: var(--radius-md);
    overflow: hidden;
}

#video-call-remote {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#video-call-local {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 180px;
    max-width: 45%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius);
    border: 2px solid rgba(255, 255, 255, 0.7);
    object-fit: cover;
}

.video-call-controls {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
}

/* Voice Call Modal */
.call-modal {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2200;
}

.call-card {
    width: min(420px, 92vw);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    text-align: center;
}

.call-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.call-avatar {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: var(--shadow-sm);
}

.call-info h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.call-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.call-controls {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
}

.call-control-btn {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.call-control-btn.accept {
    background: var(--success);
    color: var(--text-inverse);
    box-shadow: var(--shadow-sm);
}

.call-control-btn.decline,
.call-control-btn.hangup {
    background: var(--error);
    color: var(--text-inverse);
    box-shadow: var(--shadow-sm);
}

.call-control-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary,
.btn-secondary {
    padding: 10px 16px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: transform 0.2s ease, background 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary:hover {
    background: var(--border-medium);
    transform: translateY(-1px);
}

.messages-container.custom-background {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

@media (max-width: 720px) {
    .settings-row {
        grid-template-columns: 1fr;
    }
}
/* Mobile Users Modal */
.mobile-users-modal {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.9);
    backdrop-filter: blur(10px);
    z-index: 3000;
    display: flex;
    flex-direction: column;
}

.mobile-modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    margin: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.mobile-modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-close-mobile-modal {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-users-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
}

/* Mobile user item */
.mobile-user-item {
    padding: var(--space-md);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.mobile-user-item:hover {
    background: var(--bg-secondary);
}

.mobile-user-item.active {
    background: var(--primary);
    color: var(--text-inverse);
}

.mobile-user-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.mobile-user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    object-fit: cover;
}

.mobile-user-info {
    flex: 1;
}

.mobile-user-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    color: inherit;
}

.mobile-user-status {
    font-size: 13px;
    color: inherit;
    opacity: 0.8;
}

/* Fix Mobile Header for Chat Selection */
@media (max-width: 768px) {
    /* Make chat header clickable for mobile */
    .chat-header {
        cursor: pointer;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    .chat-header:active {
        background: var(--bg-secondary);
    }

    /* Add dropdown indicator */
    .chat-info::after {
        content: '\f078';
        font-family: 'Font Awesome 6 Pro';
        font-size: 12px;
        margin-left: var(--space-sm);
        color: var(--text-secondary);
        transition: transform 0.3s ease;
    }

    .mobile-modal-open .chat-info::after {
        transform: rotate(180deg);
    }

    /* Fix z-index for modals */
    .settings-modal,
    .mobile-users-modal {
        z-index: 4000;
    }
}

/* Fix for very small screens */
@media (max-width: 480px) {
    .mobile-modal-content {
        margin: 10px;
        border-radius: var(--radius-md);
    }

    .mobile-modal-header {
        padding: var(--space-md);
    }

    .mobile-user-item {
        padding: var(--space-sm);
    }

    .mobile-user-avatar {
        width: 40px;
        height: 40px;
    }
}
