/* JUSTGRAM - Premium Dark Theme */

:root {
    /* Premium Dark Color Palette */
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #242424;
    --bg-hover: #2a2a2a;
    --bg-active: #323232;

    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-tertiary: #71717a;
    --text-muted: #52525b;

    --border-color: #27272a;
    --border-light: #3f3f46;

    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;

    --message-out-bg: #6366f1;
    --message-in-bg: #27272a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

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

/* Auth Modal */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    background: var(--bg-secondary);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    font-size: 32px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.auth-tagline {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 400;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: 12px;
}

.auth-tab {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all var(--transition-fast);
}

.auth-tab.active {
    background: var(--accent-gradient);
    color: var(--text-primary);
}

.auth-tab:hover:not(.active) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    transition: all var(--transition-fast);
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.btn-primary {
    width: 100%;
    padding: 14px 20px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.auth-error {
    margin-top: 16px;
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: var(--error);
    font-size: 14px;
    text-align: center;
    display: none;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 380px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

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

.logo {
    font-size: 20px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

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

.icon-btn:active {
    transform: scale(0.95);
}

.search-box {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.search-box svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
}

.search-box input:focus {
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 4px;
}

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

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

.chat-item-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
    position: relative;
    overflow: visible;
}

.chat-item-avatar-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
}

.chat-item-avatar-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-item-avatar.online::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    background: var(--success);
    border: 2px solid var(--bg-secondary);
    border-radius: 50%;
    z-index: 10;
}

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

.chat-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.chat-item-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-item-time {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-item-message {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.unread-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--accent-gradient);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-profile {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info {
    flex: 1;
}

.user-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-status {
    display: block;
    font-size: 13px;
    color: var(--success);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    overflow: hidden;
}

.chat-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.placeholder-content {
    text-align: center;
}

.placeholder-icon {
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.placeholder-content h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.placeholder-content p {
    color: var(--text-secondary);
    font-size: 15px;
}

.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

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

.chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.chat-status {
    font-size: 13px;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px 300px;
    min-height: 0;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 65%;
    animation: messageSlide 0.3s ease;
}

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

.message.out {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
    overflow: hidden;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    display: flex;
    flex-direction: column;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

.message-sender-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-secondary);
    margin-bottom: 4px;
}

.message-text {
    display: block;
}

.message-bubble-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 4px;
}

.message-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
}

.message.in .message-time {
    color: var(--text-muted);
}

.message.in .message-bubble {
    background: var(--message-in-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message.out .message-bubble {
    background: var(--message-out-bg);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

.message-meta {
    display: none;
}

.message-edited {
    font-style: italic;
}

.read-indicator {
    display: flex;
    align-items: center;
    gap: 2px;
}

.read-indicator svg {
    width: 14px;
    height: 14px;
    color: var(--accent-secondary);
}

.message-bubble-meta .read-indicator svg {
    color: rgba(255, 255, 255, 0.7);
}

.message.out .message-bubble-meta .read-indicator svg {
    color: rgba(255, 255, 255, 0.7);
}

.message-input-area {
    padding: 13px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.attach-btn,
.emoji-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.attach-btn:hover,
.emoji-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.message-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 4px 16px;
}

.message-input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    padding: 10px 0;
}

.message-input-wrapper input:focus {
    outline: none;
}

.message-input-wrapper input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 48px;
    height: 48px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.send-btn:active {
    transform: scale(0.95);
}

/* Search Modal */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
}

.search-modal-content {
    width: 100%;
    max-width: 560px;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
}

.search-modal-header {
    display: flex;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.search-modal-header input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 15px;
}

.search-modal-header input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.close-btn {
    margin-left: 12px;
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.search-results {
    padding: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.search-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.search-user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.search-user-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.search-user-username {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 10;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .auth-container {
        margin: 20px;
        padding: 30px 24px;
    }
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Profile Modal */
.profile-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.profile-modal-content {
    width: 100%;
    max-width: 500px;
    background: var(--bg-secondary);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.profile-modal-header {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.profile-modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.profile-modal-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

.profile-avatar-section {
    text-align: center;
    margin-bottom: 32px;
}

.profile-avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 auto 16px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border: 4px solid var(--bg-tertiary);
}

.profile-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-large:hover .avatar-edit-overlay {
    opacity: 1;
}

/* Show edit button on hover for chat info avatar */
#chatInfoAvatar:hover #editChatAvatarBtn {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Show edit name button on hover */
#chatInfoName:hover #editChatNameBtn {
    display: inline-flex !important;
}

.avatar-edit-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.avatar-edit-overlay svg {
    width: 24px;
    height: 24px;
    margin-right: 8px;
}

.change-avatar-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.change-avatar-btn:hover {
    background: var(--bg-hover);
}

.profile-form-group {
    margin-bottom: 20px;
}

.profile-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.profile-form-group input,
.profile-form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.profile-form-group input:focus,
.profile-form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.profile-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.profile-form-row {
    display: flex;
    gap: 16px;
}

.profile-form-row .profile-form-group {
    flex: 1;
}

.profile-stats {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 16px;
    margin-top: 24px;
}

.profile-stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.profile-stat-item:last-child {
    border-bottom: none;
}

.profile-stat-label {
    color: var(--text-secondary);
    font-size: 13px;
}

.profile-stat-value {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.btn-save {
    width: 100%;
    padding: 14px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-top: 20px;
}

.btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.btn-cancel {
    width: 100%;
    padding: 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-top: 10px;
}

.btn-cancel:hover {
    background: var(--bg-hover);
}

/* User Profile View Modal */
.user-profile-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.user-profile-content {
    width: 100%;
    max-width: 420px;
    background: var(--bg-secondary);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.user-profile-header {
    position: relative;
    padding: 32px 24px;
    background: var(--accent-gradient);
    text-align: center;
}

.user-profile-avatar-lg {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: 600;
    color: var(--text-primary);
    border: 4px solid var(--bg-secondary);
    overflow: hidden;
}

.user-profile-avatar-lg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-profile-avatar-lg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-profile-name {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.user-profile-username {
    font-size: 14px;
    opacity: 0.8;
}

.user-profile-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    margin-top: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

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

.user-profile-body {
    padding: 24px;
}

.user-profile-bio {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 20px;
    min-height: 20px;
}

.user-profile-bio:empty::before {
    content: 'No bio yet';
    color: var(--text-muted);
    font-style: italic;
}

.user-profile-info-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.user-profile-info-item:last-child {
    border-bottom: none;
}

.user-profile-info-icon {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.user-profile-info-text {
    flex: 1;
}

.user-profile-info-label {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
}

.user-profile-info-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.user-profile-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-message {
    flex: 1;
    padding: 12px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-message:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

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

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

/* Avatar colors */
.avatar-color-1 { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); }
.avatar-color-2 { background: linear-gradient(135deg, #ec4899 0%, #f43f5e 100%); }
.avatar-color-3 { background: linear-gradient(135deg, #10b981 0%, #14b8a6 100%); }
.avatar-color-4 { background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%); }
.avatar-color-5 { background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%); }

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    animation: toastSlide 0.3s ease;
}

.toast.success {
    border-color: var(--success);
}

.toast.error {
    border-color: var(--error);
}

@keyframes toastSlide {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 90px;
    right: 24px;
    width: 360px;
    max-height: 420px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    z-index: 100;
    overflow: hidden;
    display: none;
    flex-direction: column;
}

.emoji-picker.active {
    display: flex;
}

.emoji-tabs {
    display: flex;
    gap: 4px;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.emoji-tabs::-webkit-scrollbar {
    height: 4px;
}

.emoji-tab {
    background: var(--bg-tertiary);
    border: none;
    border-radius: 8px;
    padding: 8px;
    font-size: 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

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

.emoji-tab.active {
    background: var(--accent-gradient);
}

.emoji-grid {
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    overflow-y: auto;
    max-height: 340px;
}

.emoji-item {
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    text-align: center;
    transition: all var(--transition-fast);
}

.emoji-item:hover {
    background: var(--bg-hover);
    transform: scale(1.2);
}

/* Media Messages */
.message-media {
    max-width: 320px;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 8px;
}

.message-media img,
.message-media video {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    cursor: pointer;
    border-radius: 8px;
}

.message-media video {
    cursor: default;
}

.message-media audio {
    width: 100%;
    margin-top: 8px;
}

.media-caption {
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    font-size: 14px;
}

/* File upload preview */
.upload-preview {
    position: absolute;
    bottom: 80px;
    right: 80px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    display: none;
}

.upload-preview.active {
    display: flex;
    align-items: center;
    gap: 12px;
}

.preview-image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
}

.preview-info {
    flex: 1;
}

.preview-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

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

.preview-remove {
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-remove:hover {
    background: var(--error);
    color: var(--text-primary);
}

/* Lightbox for media */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.lightbox img,
.lightbox video {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

/* ================================
   MOBILE RESPONSIVE STYLES
   ================================ */

@media (max-width: 768px) {
    /* App Container */
    .app-container {
        position: relative;
        overflow: hidden;
    }

    /* Sidebar - Full screen modal style */
    .sidebar {
        width: 100%;
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: var(--shadow-xl);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Chat Area - Full width */
    .chat-area {
        width: 100%;
    }

    /* Menu Toggle Button */
    .menu-toggle {
        display: flex !important;
        width: 36px;
        height: 36px;
        background: var(--bg-tertiary);
        border: none;
        border-radius: 10px;
        color: var(--text-primary);
        cursor: pointer;
        align-items: center;
        justify-content: center;
        margin-right: 8px;
    }

    /* Header adjustments */
    .sidebar-header {
        padding: 16px 20px;
    }

    .chat-header {
        padding: 12px 16px;
    }

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

    .chat-info h3 {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 0;
    }

    .chat-status {
        font-size: 12px;
    }

    .chat-header-actions {
        gap: 4px;
    }

    .chat-header-actions .icon-btn {
        width: 32px;
        height: 32px;
    }

    /* Chat list items */
    .chat-item {
        padding: 10px 16px;
    }

    .chat-item-avatar {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }

    .chat-item-name {
        font-size: 14px;
    }

    .chat-item-message {
        font-size: 13px;
    }

    /* Messages */
    .messages-container {
        padding: 16px 12px;
    }

    .message {
        max-width: 85%;
    }

    .message.in {
        margin-right: auto;
    }

    .message.out {
        margin-left: auto;
    }

    .message-avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .message-bubble {
        padding: 10px 12px;
        font-size: 14px;
        border-radius: 16px;
    }

    .message-media {
        max-width: 280px;
    }

    .message-media img,
    .message-media video {
        max-height: 240px;
    }

    /* Input area */
    .message-input-area {
        padding: 12px 16px;
        gap: 8px;
    }

    .attach-btn,
    .emoji-btn {
        width: 36px;
        height: 36px;
    }

    .message-input-wrapper {
        padding: 4px 12px;
    }

    .message-input-wrapper input {
        font-size: 15px;
    }

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

    /* Emoji picker - Full width on mobile */
    .emoji-picker {
        width: 100%;
        max-width: none;
        bottom: 70px;
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        max-height: 300px;
    }

    .emoji-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .emoji-item {
        font-size: 28px;
        padding: 6px;
    }

    .emoji-tabs {
        padding: 8px;
    }

    .emoji-tab {
        padding: 6px;
        font-size: 18px;
    }

    /* Upload preview */
    .upload-preview {
        left: 16px;
        right: 16px;
        bottom: 80px;
    }

    .preview-image {
        width: 50px;
        height: 50px;
    }

    /* Profile modal - Full screen */
    .profile-modal,
    .user-profile-modal,
    .search-modal {
        padding: 0;
        align-items: flex-end;
    }

    .profile-modal-content,
    .user-profile-content,
    .search-modal-content {
        width: 100%;
        max-width: none;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        margin: 0;
    }

    .profile-modal-body,
    .user-profile-body {
        max-height: calc(90vh - 80px);
    }

    .profile-avatar-large {
        width: 100px;
        height: 100px;
        font-size: 40px;
    }

    .user-profile-avatar-lg {
        width: 80px;
        height: 80px;
        font-size: 32px;
    }

    .user-profile-name {
        font-size: 20px;
    }

    /* Auth modal */
    .auth-container {
        margin: 20px;
        padding: 24px 20px;
    }

    .auth-logo {
        font-size: 28px;
    }

    /* User profile in sidebar */
    .user-profile {
        padding: 12px 16px;
    }

    .user-avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .user-name {
        font-size: 14px;
    }

    .user-status {
        font-size: 12px;
    }

    /* Placeholder */
    .placeholder-icon {
        width: 80px;
        height: 80px;
    }

    .placeholder-content h2 {
        font-size: 20px;
    }

    .placeholder-content p {
        font-size: 14px;
    }

    /* Search box */
    .search-box {
        padding: 12px 16px;
    }

    /* Lightbox */
    .lightbox img,
    .lightbox video {
        max-width: 100%;
        max-height: 100%;
    }

    .lightbox-close {
        top: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    /* Toast */
    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .message {
        max-width: 90%;
    }

    .message-bubble {
        padding: 8px 10px;
        font-size: 13px;
    }

    .emoji-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .emoji-item {
        font-size: 24px;
    }

    .chat-item-avatar {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }

    .chat-item-name {
        font-size: 13px;
    }

    .chat-item-message {
        font-size: 12px;
    }
}

/* Landscape orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .emoji-picker {
        max-height: 200px;
    }

    .profile-modal-content,
    .user-profile-content {
        max-height: 85vh;
    }
}

/* Hide desktop-only elements on mobile */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

/* Show mobile-only elements */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex !important;
    }
}

/* Create Chat/Group Option Buttons */
.create-chat-option-btn {
    width: 100%;
    padding: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: all var(--transition-fast);
    margin-bottom: 12px;
}

.create-chat-option-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.create-chat-option-btn svg {
    color: var(--accent-secondary);
}

.create-chat-option-btn span {
    font-size: 16px;
    font-weight: 600;
}

.create-chat-option-btn small {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
}

/* Chat info header */
.chat-info-header {
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 16px;
    margin-bottom: 20px;
}

.chat-info-header:hover #editChatAvatarBtn {
    opacity: 1;
}

/* Member item in list */
.chat-member-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 8px;
    background: var(--bg-tertiary);
    transition: all var(--transition-fast);
}

.chat-member-item:hover {
    background: var(--bg-hover);
}

.chat-member-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.chat-member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-member-avatar.online::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: var(--success);
    border: 2px solid var(--bg-secondary);
    border-radius: 50%;
}

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

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

.chat-member-username {
    font-size: 13px;
    color: var(--text-secondary);
}

.chat-member-role {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
}

.chat-member-role.creator {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
}

.chat-member-role.admin {
    background: var(--success);
    color: white;
}

.chat-member-role.member {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.chat-member-actions {
    display: flex;
    gap: 4px;
}

/* Date separator in chat */
.date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 24px 0;
}

.date-separator span {
    padding: 6px 16px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Readonly message input */
.message-input-area.readonly {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
    position: relative;
}

.message-input-area.readonly .message-input-wrapper,
.message-input-area.readonly #messageInput,
.message-input-area.readonly #sendBtn,
.message-input-area.readonly #attachBtn,
.message-input-area.readonly #emojiBtn {
    opacity: 0.5;
    cursor: not-allowed;
}

.message-input-area.readonly::before {
    content: '🔒';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    opacity: 0.3;
    z-index: 10;
    pointer-events: none;
}

.message-input-area.readonly::after {
    content: 'Only admins can write in this group';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    margin-bottom: 8px;
    z-index: 11;
}

/* System message in chat */
.system-message {
    text-align: center;
    padding: 8px 16px;
    margin: 12px 0;
}

.system-message span {
    display: inline-block;
    padding: 6px 16px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

