/* Modern CSS Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --primary-purple: #8b5cf6;
    --primary-purple-dark: #7c3aed;
    --primary-purple-light: #a78bfa;
    --accent-purple: #c4b5fd;
    --dark-bg: #0f0f0f;
    --darker-bg: #0a0a0a;
    --surface-dark: #1a1a1a;
    --surface-light: #2a2a2a;
    --bg-secondary: #2a2a2a;
    --border-color: #333333;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #666666;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 25px rgba(0, 0, 0, 0.25);
    --shadow-purple: 0 4px 20px rgba(139, 92, 246, 0.3);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Borders */
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 24px;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--dark-bg) 0%, var(--darker-bg) 100%);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, var(--dark-bg) 0%, var(--darker-bg) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    animation: fadeInUp 1s ease;
}

.nest-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-dark) 100%);
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-purple);
    animation: logoFloat 3s ease-in-out infinite;
}

.nest-symbol {
    font-size: 32px;
    font-weight: var(--font-weight-bold);
    color: white;
}

.nest-logo h1 {
    font-size: 48px;
    font-weight: var(--font-weight-bold);
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--accent-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loading-spinner {
    margin: 32px 0;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-purple);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

/* Authentication Container */
.auth-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--dark-bg) 0%, var(--darker-bg) 100%);
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.auth-container.hidden {
    opacity: 0;
    visibility: hidden;
}

.auth-card {
    background: var(--surface-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
    animation: slideInUp 0.6s ease;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-purple), var(--accent-purple));
}

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

.auth-header .nest-logo {
    margin-bottom: 16px;
}

.auth-header .nest-logo h1 {
    font-size: 36px;
}

.auth-header .logo-icon {
    width: 48px;
    height: 48px;
}

.auth-header .nest-symbol {
    font-size: 24px;
}

.tagline {
    color: var(--text-secondary);
    font-size: 16px;
}

.auth-form {
    transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.auth-form.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
}

.auth-form h2 {
    font-size: 24px;
    font-weight: var(--font-weight-semibold);
    margin-bottom: 24px;
    text-align: center;
}

.form-group {
    position: relative;
    margin-bottom: 24px;
}

.form-group input {
    width: 100%;
    padding: 16px 12px 8px 12px;
    background: var(--surface-light);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: 16px;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-group input:focus + label,
.form-group input:not(:placeholder-shown) + label {
    transform: translateY(-24px) scale(0.85);
    color: var(--primary-purple);
}

.form-group label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
    pointer-events: none;
    transition: all var(--transition-fast);
    background: var(--surface-light);
    padding: 0 4px;
}

.primary-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-dark) 100%);
    border: none;
    border-radius: var(--border-radius-md);
    color: white;
    font-size: 16px;
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    margin-bottom: 16px;
}

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

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

.primary-btn .btn-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
}

.primary-btn.loading .btn-loader {
    opacity: 1;
    visibility: visible;
}

.primary-btn.loading span {
    opacity: 0;
}

.auth-switch {
    text-align: center;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary-purple);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
    transition: color var(--transition-fast);
}

.auth-switch a:hover {
    color: var(--accent-purple);
}

/* Background Effects */
.auth-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}

.floating-shapes {
    position: absolute;
    width: 100%;
    height: 100%;
}

.shape {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-purple), var(--accent-purple));
    opacity: 0.1;
    animation: float 20s ease-in-out infinite;
}

.shape-1 {
    width: 80px;
    height: 80px;
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.shape-2 {
    width: 120px;
    height: 120px;
    top: 70%;
    right: 10%;
    animation-delay: -5s;
}

.shape-3 {
    width: 60px;
    height: 60px;
    top: 30%;
    right: 20%;
    animation-delay: -10s;
}

.shape-4 {
    width: 100px;
    height: 100px;
    bottom: 20%;
    left: 20%;
    animation-delay: -15s;
}

.shape-5 {
    width: 40px;
    height: 40px;
    top: 50%;
    left: 50%;
    animation-delay: -7s;
}

/* Chat Application */
.chat-app {
    display: flex;
    height: 100vh;
    background: var(--dark-bg);
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.chat-app.hidden {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--surface-dark);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-normal);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--darker-bg);
}

.nest-logo-small {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.logo-icon-small {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-dark) 100%);
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

.nest-symbol-small {
    font-size: 20px;
    font-weight: var(--font-weight-bold);
    color: white;
}

.nest-logo-small h2 {
    font-size: 24px;
    font-weight: var(--font-weight-bold);
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--accent-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--surface-light);
    border-radius: var(--border-radius-md);
    position: relative;
}

.profile-avatar {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--accent-purple) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-bold);
    position: relative;
    flex-shrink: 0;
}

.status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--surface-dark);
}

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

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

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

.profile-info span {
    display: block;
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-text {
    font-size: 12px;
    color: var(--success-color);
    margin-top: 2px;
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.logout-btn:hover {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
}

/* Online Users */
.online-users {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.online-users h3 {
    font-size: 14px;
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.users-list {
    space-y: 8px;
}

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

.user-item:hover {
    background: var(--surface-light);
}

.user-item.current-user {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--accent-purple) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: var(--font-weight-bold);
    position: relative;
    flex-shrink: 0;
}

.user-avatar .status-indicator {
    width: 10px;
    height: 10px;
    border-width: 1px;
}

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

.user-name {
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    font-size: 12px;
    color: var(--text-muted);
}

/* Creator Toggle */
.creator-toggle {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: var(--darker-bg);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    height: 72px;
}

.creator-toggle:hover {
    background: var(--surface-light);
}

.creator-toggle span {
    font-size: 26px;
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
}

.creator-toggle img {
    width: 52px;
    height: auto;
    object-fit: contain;
}

/* Main Chat Area */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--dark-bg);
}

/* Chat Header */
.chat-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.nest-title {
    display: none; /* Hidden by default, shown in mobile view */
}

.nest-title h2 {
    font-size: 24px;
    font-weight: var(--font-weight-bold);
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--accent-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.settings-btn {
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.settings-btn:hover {
    background: var(--surface-light);
    color: var(--text-primary);
    border-color: var(--primary-purple);
}

/* Messages Container */
.messages-container {
    display: flex;
    flex-direction: column;
    padding: 20px 24px;
    overflow-y: auto;
    scroll-behavior: smooth;
    flex: 1;
}

.welcome-message {
    text-align: center;
    margin: 60px 0;
    opacity: 0.7;
    display: none; /* Hidden by default, shown only when no messages */
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.welcome-icon .nest-symbol {
    font-size: 40px;
    color: white;
}

.welcome-message h3 {
    font-size: 24px;
    margin-bottom: 8px;
}

.welcome-message p {
    color: var(--text-secondary);
}

/* Message Styles */
.message {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
    max-width: 70%;
    animation: messageSlideIn 0.3s ease;
}

.message-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--accent-purple) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: var(--font-weight-semibold);
}

.own-message {
    flex-direction: row-reverse;
    align-self: flex-end;
    margin-left: auto;
}

.message-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-md);
    padding: 8px 12px;
    max-width: 100%;
    position: relative;
    cursor: pointer; /* Allow clicking to show edit history */
}

.own-message .message-content {
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-dark) 100%);
    color: white;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 0.75rem;
    gap: 12px;
}

.own-message .message-header {
    flex-direction: row-reverse;
}

.message-author {
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
}

.own-message .message-author {
    color: rgba(255, 255, 255, 0.9);
}

.message-timestamp {
    color: var(--text-muted);
    font-size: 0.6875rem;
}

.own-message .message-timestamp {
    color: rgba(255, 255, 255, 0.7);
}

.message-text {
    color: var(--text-primary);
    line-height: 1.4;
    word-wrap: break-word;
    font-size: 0.875rem;
}

.own-message .message-text {
    color: white;
}

.own-message .message-avatar {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
}

.reply-btn, .edit-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    position: absolute;
    bottom: -7px;
    display: none;
}

.reply-btn {
    right: 8px;
}

.edit-btn {
    right: 32px; /* Positioned to the left of the reply button */
}

.own-message .reply-btn, .own-message .edit-btn {
    color: rgba(255, 255, 255, 0.7);
}

.message-content:hover .reply-btn, .message-content:hover .edit-btn {
    display: block;
}

.reply-btn:hover, .edit-btn:hover {
    color: var(--primary-purple);
    background: rgba(139, 92, 246, 0.1);
}

.own-message .reply-btn:hover, .own-message .edit-btn:hover {
    color: var(--accent-purple);
    background: rgba(255, 255, 255, 0.1);
}

.quoted-message {
    background: rgba(0, 0, 0, 0.2);
    border-left: 4px solid var(--primary-purple);
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-style: italic;
    max-height: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quoted-message:hover {
    background: rgba(0, 0, 0, 0.25);
}

.own-message .quoted-message {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.85);
    border-left-color: var(--accent-purple);
}

.own-message .quoted-message:hover {
    background: rgba(255, 255, 255, 0.25);
}

.quoted-message .quote-author {
    font-weight: var(--font-weight-medium);
    margin-bottom: 4px;
    font-style: normal;
    color: var(--text-primary);
}

.own-message .quoted-message .quote-author {
    color: rgba(255, 255, 255, 0.9);
}

.quoted-message .quote-text {
    line-height: 1.3;
}

.edited-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-left: 8px;
}

.own-message .edited-label {
    color: rgba(255, 255, 255, 0.7);
}

/* Edit Message Input */
.edit-message-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.edit-message-input {
    background: var(--surface-light);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    resize: none;
    width: 100%;
}

.edit-message-input:focus {
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.own-message .edit-message-input {
    background: var(--surface-dark);
    color: white;
}

.edit-message-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.edit-save-btn, .edit-cancel-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 4px 12px;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.edit-save-btn {
    background: var(--primary-purple);
    color: white;
}

.edit-save-btn:hover {
    background: var(--primary-purple-dark);
    box-shadow: var(--shadow-sm);
}

.edit-cancel-btn {
    color: var(--text-muted);
}

.edit-cancel-btn:hover {
    color: var(--error-color);
    border-color: var(--error-color);
}

/* Edit History Modal */
.edit-history-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.edit-history-content {
    background: var(--surface-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.edit-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.edit-history-header h3 {
    font-size: 1.25rem;
    font-weight: var(--font-weight-semibold);
}

.close-modal-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.close-modal-btn:hover {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
}

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

.edit-history-item {
    background: var(--surface-light);
    border-radius: var(--border-radius-md);
    padding: 12px;
}

.edit-history-item.original {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.edit-history-item p {
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.edit-history-item span {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}

/* Typing Indicators */
.typing-indicators {
    padding: 8px 24px;
    min-height: 20px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    animation: fadeInUp 0.3s ease;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 4px;
    height: 4px;
    background: var(--primary-purple);
    border-radius: 50%;
    animation: typingDot 1.4s ease-in-out infinite both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* Replying Indicator */
.replying-indicator {
    background: var(--surface-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 8px 12px;
    margin: 8px 24px;
    display: flex;
    align-items: flex-start;
    font-size: 14px;
    color: var(--text-secondary);
}

.replying-indicator-content {
    flex: 1;
}

.replying-indicator .quote-author {
    font-weight: var(--font-weight-medium);
    margin-bottom: 4px;
    font-size: 13px;
}

.replying-indicator .quote-text {
    font-style: italic;
    line-height: 1.3;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cancel-reply-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.cancel-reply-btn:hover {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
}

/* Message Input */
.message-input-container {
    padding: 10px 10px;
    border-top: 1px solid var(--border-color);
    background: var(--surface-dark);
    display: flex;
    align-items: center;
    gap: 12px;
}

.message-input {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--dark-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-xl);
    transition: all var(--transition-fast);
    height: 50px;
}

.message-input:focus-within {
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.attachment-btn, .emoji-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-btn:hover, .emoji-btn:hover {
    color: var(--primary-purple);
    background: rgba(139, 92, 246, 0.1);
}

.message-input input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
}

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

.send-btn {
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-dark) 100%);
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 50px;
    height: 50px;
    border-radius: var(--border-radius-md);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--surface-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
    min-width: 300px;
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.3s ease;
    position: relative;
    overflow: hidden;
}

.toast::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--success-color);
}

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

.toast.warning::before {
    background: var(--warning-color);
}

.toast-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast-text h4 {
    font-weight: var(--font-weight-semibold);
    margin-bottom: 4px;
}

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

/* Animations */
@keyframes logoFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0%, 100% {
        transform: translate(0px, 0px);
    }
    33% {
        transform: translate(30px, -30px);
    }
    66% {
        transform: translate(-20px, 20px);
    }
}

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

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes toastSlideIn {
    0% {
        opacity: 0;
        transform: translateX(100%);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
        position: fixed;
        left: -280px;
        z-index: 100;
        height: 100vh;
    }

    .sidebar.open {
        transform: translateX(280px);
    }

    .main-chat {
        margin-left: 0;
    }

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

    .toast-container {
        left: 20px;
        right: 20px;
    }

    .toast {
        min-width: auto;
    }

    .message {
        max-width: 85%;
    }

    .nest-title {
        display: block;
    }

    .chat-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
    }

    .messages-container {
        padding-top: 80px;
    }

    .message-input-container {
        padding-bottom: 20px;
    }

    .edit-history-content {
        width: 95%;
    }
}

@media (max-width: 480px) {
    .messages-container {
        padding: 16px;
        padding-top: 72px;
    }

    .message-input-container {
        padding: 10px 10px;
    }

    .chat-header {
        padding: 16px;
    }

    .message {
        max-width: 90%;
    }

    .edit-history-content {
        padding: 16px;
    }
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

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

/* Selection */
::selection {
    background: rgba(139, 92, 246, 0.3);
}

/* Focus Styles */
*:focus {
    outline: 2px solid var(--primary-purple);
    outline-offset: 2px;
}

button:focus,
input:focus,
textarea:focus {
    outline: none;
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.message.highlight {
    background: rgba(139, 92, 246, 0.2);
    transition: background 0.5s ease;
}

.user-avatar-img, .message-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.message-bio, .user-bio {
    font-size: 0.8rem;
    color: #666;
    margin-top: 4px;
    max-width: 200px;
    word-wrap: break-word;
}

/* Existing styles ... */
.user-avatar-img, .message-avatar-img, .profile-picture-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}
.profile-picture-preview {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #5858a7;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 500;
}
.profile-picture-img {
    width: 64px;
    height: 64px;
}
.message-bio, .user-bio {
    font-size: 0.8rem;
    color: #d1d1f1;
    margin-top: 4px;
    max-width: 200px;
    word-wrap: break-word;
}
.primary-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    overflow: hidden;
}
.btn-loader {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.primary-btn.loading .btn-loader {
    display: block;
}
.primary-btn.loading span {
    visibility: hidden;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.clear-chat-btn {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 8px;
}

.clear-chat-btn:hover {
    color: #c82333;
}

.clear-chat-confirm {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: #2c2c54;
    padding: 12px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.clear-chat-confirm.hidden {
    display: none;
}

.clear-chat-confirm p {
    font-size: 14px;
    color: #d1d1f1;
    margin: 0;
}

.clear-chat-confirm .primary-btn,
.clear-chat-confirm .secondary-btn {
    padding: 8px 16px;
    font-size: 14px;
}

.primary-btn {
    background: #5858a7;
    border: none;
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    padding: 10px 16px;
    font-size: 16px;
    font-weight: 500;
    transition: background 0.2s;
}

.primary-btn:hover {
    background: #4b4b8c;
}

.primary-btn.loading .btn-loader {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 0.5s linear infinite;
    margin-left: 8px;
}

.secondary-btn {
    background: #3b3b6a;
    border: none;
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    padding: 10px 16px;
    font-size: 16px;
    font-weight: 500;
    transition: background 0.2s;
}

.secondary-btn:hover {
    background: #444479;
}

.btn-loader {
    display: none;
}

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

.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #2c2c54;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    color: #ffffff;
    font-size: 14px;
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.3s, transform 0.3s;
}

.toast.success {
    border-left: 4px solid #28a745;
}

.toast.error {
    border-left: 4px solid #dc3545;
}

.toast.warning {
    border-left: 4px solid #ffc107;
}

.toast.info {
    border-left: 4px solid #17a2b8;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(100%);
}

.toast-icon svg {
    width: 20px;
    height: 20px;
}

.toast-text h4 {
    font-size: 14px;
    font-weight: 500;
    margin: 0;
}

.toast-text p {
    font-size: 12px;
    margin: 0;
}

.hidden {
    display: none;
}