/* Ribyl - Modern Mobile Chat App */
/* Version: 1.6.98 - Update profile page layout, backgrounds, and database integration */

/* List Styles (v1.6.77) - General list styling */
ul, ol, li {
    background: #000;
}

/* Message Reactions (v1.6.58) - Clean individual containers */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    background: transparent;
    border: none;
    padding: 0;
    width: 100%;
    max-width: 250px; /* Match message bubble width */
}

/* Left-aligned reactions for incoming messages */
.message:not(.own) .message-reactions {
    justify-content: flex-start;
    margin-left: 0;
    margin-right: auto;
    align-self: flex-start;
}

/* Right-aligned reactions for outgoing messages */
.message.own .message-reactions {
    justify-content: flex-end;
    margin-left: auto;
    margin-right: 0;
    align-self: flex-end;
}

/* Message container layout for proper alignment */
.message {
    display: flex;
    flex-direction: column;
    margin-bottom: var(--spacing-sm);
}

/* Incoming messages align to left */
.message:not(.own) {
    align-items: flex-start;
}

/* Outgoing messages align to right */
.message.own {
    align-items: flex-end;
}

.message-reactions .reaction {
    background: #171717; /* Dark background for individual containers */
    border: 1px solid var(--border-color);
    border-radius: 8px; /* Square containers with slight rounding */
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    color: var(--text-color);
    white-space: nowrap;
}

.message-reactions .reaction.removable {
    cursor: pointer;
    opacity: 1;
}

.message-reactions .reaction:not(.removable) {
    cursor: default;
    opacity: 0.8;
}

/* Removed hover effects for smooth experience */

/* Align reactions properly for own vs other messages */
.message.own .message-reactions {
    justify-content: flex-end;
    margin-right: var(--spacing-md);
}

.message.other .message-reactions {
    justify-content: flex-start;
    margin-left: var(--spacing-md);
}

/* CSS Variables - Dark Mode (Default) */
:root {
    /* Dark mode colors */
    --primary-color: #0A84FF;
    --primary-hover: #3395FF;
    --primary-light: rgba(10, 132, 255, 0.25);

    --secondary-color: #8E8E93;

    --background-color: #000000;
    --surface-color: #1C1C1E;
    --elevated-color: #2C2C2E;

    --text-primary: #FFFFFF;
    --text-secondary: #D1D1D6;
    --text-tertiary: #8E8E93;

    --border-color: rgba(55, 55, 55, 0.40);

    --success-color: #34C759;
    --warning-color: #FF9500;
    --error-color: #FF3B30;

    --shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.8);
    
    /* Additional variables */
    --border-radius: 30px;
    --border-radius-large: 30px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-md: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 20px;
    --font-size-xxl: 24px;
    --transition: all 0.2s ease;
}

/* Light Mode Colors */
:root.light {
    /* Light mode colors */
    --primary-color: #0A84FF;
    --primary-hover: #0066CC;
    --primary-light: rgba(10, 132, 255, 0.15);

    --secondary-color: #6E6E73;

    --background-color: #FFFFFF;
    --surface-color: #F9F9FB;
    --elevated-color: #FFFFFF;

    --text-primary: #111111;
    --text-secondary: #3A3A3C;
    --text-tertiary: #6E6E73;

    --border-color: rgba(200, 200, 200, 0.60);

    --success-color: #34C759;
    --warning-color: #FF9500;
    --error-color: #FF3B30;

    --shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Theme transition */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* =========================
   DESIGN LANGUAGE FOUNDATION
   ========================= */

/* =========================
   CONSISTENT DESIGN SYSTEM
   ========================= */

/* Standardized Component Sizes */
:root {
    /* Component Heights */
    --component-height-xs: 32px;
    --component-height-sm: 40px;
    --component-height-md: 44px;
    --component-height-lg: 48px;
    --component-height-xl: 56px;
    
    /* Component Widths */
    --component-width-xs: 80px;
    --component-width-sm: 120px;
    --component-width-md: 160px;
    --component-width-lg: 200px;
    --component-width-xl: 240px;
    
    /* Standardized Spacing */
    --spacing-xxs: 2px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-xxl: 48px;
    
    /* Border Radius System */
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-xxl: 24px;
    --radius-full: 50%;
    
    /* Font Size System */
    --text-xs: 12px;
    --text-sm: 14px;
    --text-md: 16px;
    --text-lg: 18px;
    --text-xl: 20px;
    --text-xxl: 24px;
    --text-xxxl: 28px;
}

/* Typography Foundation */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--background-color);
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--text-primary);
}

h1 { font-size: 28px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
h4 { font-size: 18px; }
h5 { font-size: 16px; }
h6 { font-size: 14px; }

p {
    margin: 0 0 16px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Card Components */
.card {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.card-compact {
    padding: 12px;
    border-radius: 12px;
}

.card-large {
    padding: 24px;
    border-radius: 20px;
}

/* Modal / Bottom Sheet Components */
.modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--elevated-color);
    border-radius: 24px 24px 0 0;
    padding: 24px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    animation: slide-up 0.3s ease-out;
    z-index: 1000;
}

.modal-handle {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--text-tertiary);
    margin: 0 auto 12px;
}

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

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

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

/* Button Components */
.button {
    background: var(--primary-color);
    color: #fff;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    font-size: var(--text-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    text-decoration: none;
    height: var(--component-height-md);
    min-height: var(--component-height-md);
    box-sizing: border-box;
}

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

.button:active {
    transform: translateY(0);
}

.button.secondary {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.button.secondary:hover {
    background: var(--primary-light);
}

.button.destructive {
    background: var(--error-color);
}

.button.destructive:hover {
    background: var(--error-color);
}

.button.success {
    background: var(--success-color);
}

.button.success:hover {
    background: var(--success-color);
}

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

.button.warning:hover {
    background: var(--warning-color);
}

.button-small {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--text-sm);
    border-radius: var(--radius-sm);
    height: var(--component-height-sm);
    min-height: var(--component-height-sm);
}

.button-large {
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: var(--text-lg);
    border-radius: var(--radius-lg);
    height: var(--component-height-lg);
    min-height: var(--component-height-lg);
}

.button-full {
    width: 100%;
}

/* Input Components */
.input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: var(--text-md);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    height: var(--component-height-md);
    min-height: var(--component-height-md);
}

.input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

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

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

.input-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

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

.input-error:focus {
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.15);
}

.error-message {
    color: var(--error-color);
    font-size: 14px;
    margin-top: 4px;
}

/* Animation Keyframes */
@keyframes slide-up {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

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

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* Utility Classes */
.fade-in {
    animation: fade-in 0.3s ease-out;
}

.scale-in {
    animation: scale-in 0.2s ease-out;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.p-0 { padding: 0; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.p-4 { padding: 32px; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-column { display: flex; flex-direction: column; }

.hidden { display: none; }
.visible { display: block; }

/* Dark mode toggle styles */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: var(--surface-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--primary-light);
}

.theme-toggle-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--text-primary);
    font-weight: 500;
}

.theme-toggle-icon {
    width: 20px;
    height: 20px;
    fill: var(--text-secondary);
}

.theme-switch {
    position: relative;
    width: 50px;
    height: 30px;
    background: var(--border-color);
    border-radius: 15px;
    cursor: pointer;
    transition: var(--transition);
}

.theme-switch.active {
    background: var(--primary-color);
}

.theme-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 26px;
    height: 26px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.theme-switch.active .theme-switch-thumb {
    transform: translateX(20px);
}
/* Base styles */

/* Light mode visibility improvements */

.profile-section {
    padding: var(--spacing-lg) var(--spacing-md);
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: var(--surface-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: var(--transition);
}

.settings-item:hover {
    background: var(--primary-light);
}

.result-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: #000000;
    border: 1px solid rgba(55, 55, 55, 0.40);
    cursor: pointer;
    min-height: var(--component-height-xl);
    flex-shrink: 0;
    border-radius: var(--radius-xl);
    margin: 0px var(--spacing-md) var(--spacing-md);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    z-index: 1;
}

.result-item:hover {
    background: #000000;
}

.result-item:active {
    background: #1c1c1e;
}

.delete-recent-search-btn {
    position: absolute;
    right: var(--spacing-md);
    top: 25%;
    transform: translateY(-50%);
    background: rgb(255 255 255 / 0%);
    border: none;
    color: #48484a;
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    transition: var(--transition);
    z-index: 10;
}

.delete-recent-search-btn:hover {
    background: rgb(0 0 0 / 10%);
    color: #48484a;
}

.profile-action-btn {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: var(--surface-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: var(--transition);
}

.logout-btn {
    background: var(--error-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.attach-btn {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.tab-btn.active {
    color: white;
    background: var(--surface-color);
    box-shadow: none;
}

.member-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border-radius: 30px;
    margin-bottom: var(--spacing-sm);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.read-status.read {
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    gap: 4px;
}

.avatar-upload-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface-color);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
}

/* PWA Optimizations - Prevent zoom and control scrolling */
* {
    -webkit-text-size-adjust: 100%;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* Allow text selection in input fields and text areas */
input, textarea, [contenteditable] {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Prevent zoom on double tap and control scrolling */
html, body {
    touch-action: pan-x pan-y;
    overflow: hidden;
    height: 100%;
    width: 100%;
    position: fixed;
}

/* Toast animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

/* Dark mode variables */
.dark-mode {
    --background-color: #000000;
    --surface-color: #1C1C1E;
    --text-primary: #FFFFFF;
    --text-secondary: #8E8E93;
    --text-tertiary: #48484A;
    --border-color: #38383A;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Mobile-specific improvements */
@media (max-width: 480px) {
    /* Prevent text overflow */
    .chat-name, .chat-preview, .message-content, .profile-name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
    }
    
    /* Improve touch targets */
    button, .chat-item, .nav-item, .settings-item {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better spacing for small screens */
    .form-group {
        margin-bottom: var(--spacing-md);
    }
    
    .settings-section {
        margin-bottom: var(--spacing-lg);
    }
    
    /* Improve search input */
    .search-box input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Better message bubbles */
    .message-bubble {
        max-width: 85%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

/* Tablet improvements */
@media (min-width: 481px) and (max-width: 768px) {
    .content-area {
        padding-bottom: 0;
    }
    
    /* Bottom nav padding handled by main .bottom-nav rule */
    
    .nav-item {
        padding: var(--spacing-sm);
        gap: 0;
    }
    
    .nav-item svg {
        width: 40px;
        height: 40px;
    }
}

/* Desktop improvements */
@media (min-width: 769px) {
    .content-area {
        max-width: 800px;
        margin: 0 auto;
    }
    
    .login-card {
        max-width: 450px;
    }
}

/* Universal Modal System */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { 
        opacity: 0; 
        backdrop-filter: blur(0px);
    }
    to { 
        opacity: 1; 
        backdrop-filter: blur(8px);
    }
}

/* All modals use this base styling */
.group-chat-modal,
.chat-details-modal {
    background: var(--surface-color);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: modalSlideIn 0.3s ease-out;
}

.chat-details-modal {
    max-width: 600px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close-btn {
    background: var(--surface-color);
    border: none;
    font-size: 20px;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-weight: bold;
    line-height: 1;
    position: relative;
}

.modal-close-btn::before {
    content: "×";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    font-weight: bold;
    line-height: 1;
}

.modal-close-btn:hover {
    background: var(--surface-color);
    color: var(--primary-color);
    transform: scale(1.1);
}

.modal-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--surface-color);
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--surface-color);
    border-radius: 0 0 20px 20px;
}

.modal-footer button {
    flex: 1;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-secondary {
    background: var(--background-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: var(--spacing-sm) var(--spacing-md);
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

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

.btn-primary {
    background: var(--primary-color);
    color: white;
    border-radius: 30px;
    padding: var(--spacing-sm) var(--spacing-md);
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

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

.btn-primary:disabled {
    background: var(--text-tertiary);
    cursor: not-allowed;
}

.user-search-box {
    margin-bottom: var(--spacing-md);
}

.user-search-box input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: var(--font-size-md);
    font-weight: 500;
}

.user-search-box input:focus {
    outline: none;
    background: var(--surface-color);
    border-color: var(--primary-color);
}

.selected-users {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
    min-height: 40px;
    padding: var(--spacing-sm);
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    background: var(--surface-color);
}

.selected-user {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: var(--primary-color);
    color: white;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 12px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.selected-user .user-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    border: none;
}

.selected-user .remove-user {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.selected-user .remove-user:hover {
    background: rgba(255, 255, 255, 0.2);
}

.user-list {
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    padding: var(--spacing-xs);
}

.user-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-xl);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    background: var(--surface-color);
    margin-bottom: var(--spacing-xs);
}

.user-item.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: var(--spacing-sm) var(--spacing-xl);
}

.user-item.selected .user-avatar {
    border-color: white;
}

.user-item .user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    object-fit: cover;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.user-item .user-name {
    font-weight: 600;
    font-size: var(--font-size-md);
    margin-bottom: 2px;
    color: var(--text-primary);
}

.user-item .user-status {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.user-item.selected .user-status {
    color: rgba(255, 255, 255, 0.8);
}

.user-item .select-indicator {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    background: var(--background-color);
}

.user-item.selected .select-indicator {
    background: white;
    border-color: white;
}

.user-item.selected .select-indicator::after {
    content: '✓';
    color: var(--primary-color);
    font-size: 12px;
    font-weight: bold;
}

/* Avatar Upload Components */
.avatar-upload-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    align-items: center;
}

.avatar-upload-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface-color);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
}

.avatar-upload-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

@media (max-width: 480px) {
    .group-chat-modal {
        width: 95%;
        border-radius: 30px;
    }
    
    .modal-header {
        padding: var(--spacing-md);
    }
    
    .modal-content {
        padding: var(--spacing-md);
    }
    
    .modal-footer {
        padding: var(--spacing-sm) var(--spacing-md) var(--spacing-md);
    }
    
    .user-list {
        max-height: 250px;
    }
}

/* Chat Details Modal - inherits from universal modal system */

.chat-info-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    background: var(--background-color);
    border-radius: 16px;
    margin: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.chat-avatar-large {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-color);
    flex-shrink: 0;
    font-size: 32px;
}

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

.chat-info-text h3 {
    margin: 0 0 var(--spacing-xs) 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.chat-info-text p {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.chat-details-tabs {
    display: flex;
    background: var(--surface-color);
    border-radius: 12px;
    padding: 4px;
    margin: var(--spacing-md) 0;
    border: none;
}

.tab-btn {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
}

.tab-btn.active {
    color: white;
    background: var(--surface-color);
    box-shadow: none;
}

.no-media-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    background: rgba(255, 165, 0, 0.1);
    border-radius: 12px;
    margin: var(--spacing-md) 0;
    font-size: 14px;
}

.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-content.active {
    display: block;
}

.members-list {
    padding: var(--spacing-md);
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.member-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border-radius: 30px;
    margin-bottom: var(--spacing-sm);
    background: var(--background-color);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.member-item:hover {
    background: var(--surface-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.member-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    position: relative;
}

.member-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.member-avatar.online::after {
    background: var(--success-color);
}

.member-avatar.away::after {
    background: var(--warning-color);
}

.member-avatar.offline::after {
    background: var(--warning-color);
}

.member-info {
    flex: 1;
}

.member-name {
    font-weight: 600;
    font-size: var(--font-size-md);
    color: var(--text-primary);
    margin-bottom: 2px;
}

.member-status {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.member-role {
    font-size: var(--font-size-xs);
    color: var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
}

.member-activity {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin-top: 2px;
}

.media-grid {
    padding: var(--spacing-md);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--spacing-sm);
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.media-item {
    aspect-ratio: 1;
    border-radius: 30px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid var(--border-color);
    background: var(--surface-color);
}

.media-item:hover {
    transform: scale(1.05);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-danger {
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 30px;
    padding: var(--spacing-md);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-danger:hover {
    background: var(--error-color);
}

@media (max-width: 480px) {
    .chat-details-modal {
        width: 95%;
        border-radius: 30px;
    }
    
    .chat-info-section {
        padding: var(--spacing-md);
        gap: var(--spacing-sm);
        margin: 12px;
        border-radius: 12px;
    }
    
    .chat-avatar-large {
        width: 50px;
        height: 50px;
        font-size: 28px;
    }
    
    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: var(--spacing-xs);
    }
    
    .media-item {
        border-radius: 30px;
    }
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Splash Screen */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease-out;
}

.splash-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.splash-logo {
    width: 200px;
    height: 200px;
    animation: splashPulse 2s ease-in-out infinite;
    object-fit: contain;
    border-radius: 30px;
    box-sizing: border-box;
}

.loading-dots {
    display: flex;
    gap: 8px;
}

.loading-dots span {
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: loadingBounce 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes splashPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

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

/* Prevent login screen flash */
#loginScreen {
    display: none;
}

#loginScreen.active {
    display: block;
}

/* Removed skeleton loading animations for smoother experience */

/* Sending Indicator */
.sending-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    margin: 8px 0;
    background: var(--surface-color);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    /* Animation removed for faster loading */
}

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

.sending-dots span {
    width: 6px;
    height: 6px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: sendingPulse 1.4s ease-in-out infinite both;
}

.sending-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.sending-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

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

/* Enhanced Animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Apply animations to key elements */
.chat-item {
    /* Animation removed for smoother loading */
}

.message {
    /* Animation removed for smoother loading */
}

.modal {
    /* Animation removed for faster loading */
}

.tab-content.active {
    /* Animation removed for faster loading */
}

.message-bubble {
    /* Animation removed for smoother loading */
}

/* Remove ALL transitions and animations for smooth, static experience */
*, *::before, *::after {
    transition: none !important;
    animation: none !important;
    transform: none !important;
}

button, input, .chat-item, .message, .modal, .tab-content, .screen {
    transition: none !important;
    animation: none !important;
}

/* Lock the shell so it never scrolls */
html, body {
    height: 100%;
    overflow: hidden; /* stop background/shell scrolling */
    margin: 0;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    font-smoothing: antialiased;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* Mobile-first responsive design */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    body {
        font-size: 14px;
    }
}

@media (min-width: 769px) {
    html {
        font-size: 16px;
    }
    
    body {
        font-size: 16px;
    }
}

/* Screen management */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
}

.screen.active {
    display: block;
}

/* Login Screen */
.login-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    position: relative;
}

.login-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(30px);
    border-radius: var(--border-radius-large);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
}

@media (max-width: 480px) {
    .login-container {
        padding: var(--spacing-sm);
    }
    
    .login-card {
        padding: var(--spacing-lg);
        margin: var(--spacing-sm);
        max-width: calc(100% - 2rem);
    }
}

.login-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.app-logo {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 20px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.profile-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.app-icon {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--spacing-lg);
    color: white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.app-title {
    font-size: var(--font-size-xxl);
    font-weight: 700;
    color: white;
    margin-bottom: var(--spacing-sm);
}

.app-subtitle {
    font-size: var(--font-size-md);
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.login-form {
    margin-bottom: var(--spacing-lg);
}

.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    font-size: var(--font-size-md);
    font-weight: 600;
    color: white;
    margin-bottom: var(--spacing-sm);
}

.form-group input {
    width: 100%;
    padding: 16px 20px;
    border: 1px solid var(--border-color);
    border-radius: 30px;
    background: rgb(23, 23, 23);
    color: rgb(255, 255, 255);
    font-size: var(--font-size-md);
    font-weight: 500;
    transition: var(--transition);
}

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

.form-group input:focus {
    outline: none;
    background: var(--surface-color);
}

.login-button {
    width: 100%;
    padding: 18px 24px;
    background: white;
    color: var(--primary-color);
    border: none;
    border-radius: var(--border-radius);
    font-size: var(--font-size-lg);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.login-button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.95);
}

.login-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-spinner.hidden {
    display: none;
}

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

.signup-link {
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: var(--font-size-md);
}

.signup-link a {
    color: white;
    text-decoration: none;
    font-weight: 600;
}

.signup-link a:hover {
    text-decoration: none;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: var(--spacing-lg) 0;
    text-align: center;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.3);
}

.auth-divider span {
    padding: 0 var(--spacing-md);
    color: rgba(255, 255, 255, 0.8);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

/* Main App */
.content-area {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--background-color);
    overflow: hidden;
    position: relative;
}

@media (max-width: 480px) {
    .content-area {
        padding-bottom: 0;
    }
}

.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
    height: 100%;
    flex-direction: column;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Page Headers */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg) var(--spacing-md) var(--spacing-md);
    background: var(--background-color);
    min-height: 60px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.back-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-btn:hover {
    background: var(--surface-color);
    color: var(--text-primary);
}

/* Messages page header - buttons on the right only */
#messagesTab .page-header {
    justify-content: flex-end;
}

.edit-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: var(--spacing-xs);
    transition: opacity 0.2s ease;
}

.edit-btn:hover {
    opacity: 0.7;
}

@media (max-width: 480px) {
    .page-header {
        padding: var(--spacing-md) var(--spacing-sm);
        min-height: 56px;
    }
}

.header-actions {
    display: flex;
    gap: var(--spacing-sm);
}

/* Search page header - align to right */
#searchTab .header-actions {
    justify-content: flex-end;
}

.page-title {
    font-size: var(--font-size-xxl);
    font-weight: 700;
    color: var(--text-primary);
    text-align: left;
    margin: 0;
}

.new-group-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.new-chat-btn,
.new-group-btn,
.invite-btn,
.logout-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.new-chat-btn svg {
    width: 16px;
    height: 16px;
}

.new-group-btn {
    background: var(--surface-color);
    color: var(--text-primary);
}

.new-group-btn:hover {
    background: var(--surface-color);
    color: white;
}

.new-chat-btn:hover,
.invite-btn:hover {
    background: var(--primary-color);
}

/* Invite button styling to match section title */
.invite-btn {
    background: transparent !important;
    color: var(--text-primary) !important;
    font-size: var(--font-size-lg) !important;
    font-weight: 600 !important;
}

.invite-btn:hover {
    background: transparent !important;
    color: var(--text-primary) !important;
}

.logout-btn {
    background: var(--error-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.logout-btn:hover {
    background: var(--error-color);
}

/* Chat Search */
.chat-search-container {
    padding: var(--spacing-sm) var(--spacing-md) var(--spacing-md) var(--spacing-md);
    background: var(--background-color);
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 16px;
    color: var(--primary-color);
    z-index: 1;
}

.mic-icon {
    position: absolute;
    right: 16px;
    color: var(--primary-color);
    z-index: 1;
    cursor: pointer;
    transition: color 0.2s ease;
}

.mic-icon:hover {
    color: var(--primary-color);
}

.chat-search-input {
    width: 100%;
    padding: var(--spacing-md) var(--spacing-lg) var(--spacing-md) 52px;
    border: 1px solid rgb(55 55 55 / 40%);
    border-radius: var(--radius-xl);
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: var(--text-md);
    font-weight: 500;
    outline: none;
    transition: var(--transition);
    height: calc(var(--component-height-md) + 10px);
    min-height: calc(var(--component-height-md) + 10px);
    box-sizing: border-box;
}

.chat-search-input:focus {
    background: var(--surface-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.chat-search-input::placeholder {
    color: var(--text-tertiary);
}

@media (max-width: 480px) {
    .chat-search-container {
        padding: var(--spacing-xs) var(--spacing-sm) var(--spacing-sm) var(--spacing-sm);
    }
    
    .chat-search-input {
        padding: var(--spacing-sm) var(--spacing-md) var(--spacing-sm) 48px;
        font-size: var(--text-md);
        height: calc(var(--component-height-sm) + 10px);
        min-height: calc(var(--component-height-sm) + 10px);
    }
    
    .search-icon {
        left: 16px;
        width: 20px;
        height: 20px;
    }
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
    background: var(--background-color);
    -webkit-overflow-scrolling: touch;
    padding: 12px 0;
}

/* Tablet and up */
@media (min-width: 481px) {
    .chat-list {
        padding: 16px 0;
    }
}

/* Desktop and up */
@media (min-width: 769px) {
    .chat-list {
        padding: 20px 0;
    }
}

.chat-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: #000000;
    border: 1px solid rgba(55, 55, 55, 0.40);
    cursor: pointer;
    min-height: var(--component-height-xl);
    flex-shrink: 0;
    border-radius: var(--radius-xl);
    margin: 0px var(--spacing-md) var(--spacing-md);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    z-index: 1;
}

.chat-item:active {
    background: #1c1c1e;
}



/* Delete Confirmation Modal */
.delete-confirmation-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.delete-confirmation-modal.show {
    opacity: 1;
    visibility: visible;
}

.delete-confirmation-content {
    background: var(--surface-color);
    border-radius: 30px;
    padding: 24px;
    max-width: 320px;
    width: 90%;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.delete-confirmation-modal.show .delete-confirmation-content {
    transform: scale(1);
}

.delete-confirmation-content h3 {
    color: white;
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
}

.delete-confirmation-content p {
    color: var(--text-secondary);
    margin: 0 0 24px 0;
    font-size: 14px;
    line-height: 1.4;
}

.delete-confirmation-buttons {
    display: flex;
    gap: 12px;
}

.delete-confirmation-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.delete-confirmation-btn.cancel {
    background: var(--secondary-color);
    color: white;
}

.delete-confirmation-btn.confirm {
    background: var(--error-color);
    color: white;
}

.delete-confirmation-btn:hover {
    transform: translateY(-1px);
}

/* Username Change Modal */
#usernameChangeModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#usernameChangeModal.show {
    opacity: 1;
    visibility: visible;
}

#usernameChangeModal .modal-content {
    background: var(--surface-color);
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

#usernameChangeModal.show .modal-content {
    transform: scale(1);
}

#usernameChangeModal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--surface-color);
    border-radius: 20px 20px 0 0;
}

#usernameChangeModal .modal-header h3 {
    color: white;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

#usernameChangeModal .modal-body {
    flex: 1;
    padding: 20px 24px;
    background: var(--surface-color);
}

#usernameChangeModal .modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--surface-color);
    border-radius: 0 0 20px 20px;
}

#usernameChangeModal .form-group {
    margin-bottom: 0;
}

#usernameChangeModal .form-group label {
    display: block;
    color: white;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
}

#usernameChangeModal .form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 30px;
    background: rgb(23, 23, 23);
    color: rgb(255, 255, 255);
    font-size: 16px;
    outline: currentcolor;
    transition: 0.2s;
    box-sizing: border-box;
}

#usernameChangeModal .form-group input:focus {
    background: rgb(22, 22, 22);
    border-color: rgb(31, 31, 31);
    box-shadow: 0 0 0 1.5px #1f1f1f;
}

#usernameChangeModal .form-group input::placeholder {
    color: var(--text-tertiary);
}

#usernameChangeModal .btn-secondary {
    flex: 1;
    padding: 12px 20px;
    border-radius: 30px;
    font-weight: 500;
    background: var(--surface-color);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

#usernameChangeModal .btn-secondary:hover {
    background: var(--surface-color);
    transform: translateY(-1px);
}

#usernameChangeModal .btn-primary {
    flex: 1;
    padding: 12px 20px;
    border-radius: 30px;
    font-weight: 500;
    background: var(--success-color);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

#usernameChangeModal .btn-primary:hover {
    background: var(--success-color);
    transform: translateY(-1px);
}

/* Success Modal Styles */
.success-message {
    text-align: center;
    padding: var(--spacing-lg);
}

.success-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--success-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    margin: 0 auto var(--spacing-md);
}

.success-message p {
    color: var(--text-primary);
    font-size: 16px;
    margin: 0;
}

/* In-App Notification Animations */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

/* In-App Notification Styles */
.in-app-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--surface-color);
    color: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    max-width: 300px;
    animation: slideInRight 0.3s ease-out;
    border: 1px solid var(--border-color);
}

.in-app-notification .notification-content h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.in-app-notification .notification-content p {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.in-app-notification .notification-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.in-app-notification .notification-close:hover {
    color: white;
}

/* User List Modal */
.user-list-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.user-list-modal.show {
    opacity: 1;
    visibility: visible;
}

.user-list-content {
    background: var(--surface-color);
    border-radius: 30px;
    padding: 0;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.user-list-modal.show .user-list-content {
    transform: scale(1);
}

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

.user-list-header h3 {
    color: white;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.close-user-list-btn {
    background: var(--surface-color);
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-user-list-btn:hover {
    background: var(--surface-color);
    color: var(--primary-color);
}

.user-list {
    max-height: 60vh;
    overflow-y: auto;
    padding: 8px 0;
}

.user-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    cursor: pointer;
    transition: background 0.2s ease;
}

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

.user-list-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--surface-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}

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

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

.user-list-name {
    font-size: 16px;
    font-weight: 600;
    color: white;
    margin: 0 0 2px 0;
    line-height: 1.2;
}

.user-list-username {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.2;
}

.user-list-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--success-color);
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .chat-item {
        padding: var(--spacing-sm) var(--spacing-md);
        gap: var(--spacing-sm);
        min-height: var(--component-height-lg);
        margin: 0 var(--spacing-sm) var(--spacing-sm) var(--spacing-sm);
    }
    
    .result-item {
        padding: var(--spacing-sm) var(--spacing-md);
        gap: var(--spacing-sm);
        min-height: var(--component-height-lg);
        margin: 0 var(--spacing-sm) var(--spacing-sm) var(--spacing-sm);
    }
}

.chat-avatar {
    font-size: var(--text-lg);
    width: var(--component-height-lg);
    height: var(--component-height-lg);
    background: var(--surface-color);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden !important;
    position: relative;
    font-weight: 600;
    color: white;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* Force proper cropping for all avatar images */
.chat-avatar img,
.chat-avatar img[src*="data:image"],
.chat-avatar img[src*="http"] {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
}


.chat-avatar .group-avatars {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chat-name {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 2px 0;
    line-height: 1.2;
}

.chat-preview {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    line-height: 1.2;
}

.chat-time {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin: 0;
    text-align: right;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 2px;
}

.chat-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.unread-badge {
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    padding: 0 4px;
}

.read-receipt {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    flex-shrink: 0;
}

.read-receipt.read {
    background: var(--primary-color);
}

/* Chat Conversation */
.chat-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--background-color);
    min-height: 60px;
    flex-shrink: 0;
    border-bottom: none; /* Remove border to match image */
    position: sticky;
    top: 0;
    z-index: 100;
}

@media (max-width: 480px) {
    .chat-header {
        padding: var(--spacing-md) var(--spacing-lg);
        gap: var(--spacing-sm);
        min-height: 60px;
    }
}

.back-btn {
    background: var(--surface-color);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-full);
    transition: var(--transition);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: -8px; /* Move further left */
}

.back-btn:hover {
    background: var(--surface-color);
}

.back-btn svg {
    width: 20px;
    height: 20px;
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1;
    min-width: 0;
}

.chat-header .chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.chat-header .chat-avatar:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.chat-user-details h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.chat-user-details .status {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 400;
}

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

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

.chat-header .action-btn:hover {
    background: var(--surface-color);
}

.chat-header .action-btn svg {
    width: 20px;
    height: 20px;
}

.chat-avatar {
    font-size: var(--text-lg);
    width: var(--component-height-md);
    height: var(--component-height-md);
    background: var(--surface-color);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    object-fit: cover;
}

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

/* Group chat multiple avatars - overlapping circular style */
.group-avatars {
    position: relative;
    width: 100%;
    height: 100%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.group-avatar {
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: none; /* Remove box shadow */
}

.group-avatar:nth-child(1) {
    top: 4px;
    left: 4px;
    z-index: 3;
}

.group-avatar:nth-child(2) {
    top: 4px;
    right: 4px;
    z-index: 2;
}

.group-avatar:nth-child(3) {
    bottom: 4px;
    left: 8px;
    z-index: 1;
}

.group-avatar:nth-child(4) {
    bottom: 4px;
    right: 8px;
    z-index: 0;
}

.group-member-count {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: var(--primary-color);
    color: white;
    font-size: 9px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--background-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

@media (max-width: 480px) {
    .chat-avatar {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .group-avatar {
        width: 28px;
        height: 28px;
    }
    
    .group-avatar:nth-child(1) {
        top: 3px;
        left: 3px;
    }
    
    .group-avatar:nth-child(2) {
        top: 3px;
        right: 3px;
    }
    
    .group-avatar:nth-child(3) {
        bottom: 3px;
        left: 6px;
    }
    
    .group-avatar:nth-child(4) {
        bottom: 3px;
        right: 6px;
    }
    
    .group-member-count {
        width: 16px;
        height: 16px;
        font-size: 8px;
    }
}

.chat-user-details {
    flex: 1;
    min-width: 0; /* Allow text to truncate */
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.chat-user-details h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .chat-user-details h3 {
        font-size: var(--font-size-md);
    }
}

.status {
    font-size: var(--font-size-sm);
}

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

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

.status.offline {
    color: var(--warning-color);
}

.chat-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.action-btn {
    background: var(--surface-color);
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-full);
    transition: var(--transition);
    width: var(--component-height-md);
    height: var(--component-height-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: var(--surface-color);
    color: var(--primary-color);
    transform: none;
}

.action-btn:active {
    background: var(--surface-color);
    color: var(--primary-color);
    transform: none;
}

.action-btn:focus {
    outline: none;
    border: none;
    box-shadow: none;
}

/* Chat Actions Bar */
.chat-actions-bar {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.action-pill {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 30px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.action-pill:hover {
    background: var(--surface-color);
    color: var(--text-secondary);
}

.action-pill.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Media Links */
.media-links {
    display: flex;
    gap: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
}

.media-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: var(--transition);
}

.media-link:hover {
    text-decoration: none;
}

/* Read Receipts */
.read-receipts {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--spacing-xs);
    padding-top: var(--spacing-xs);
}

.read-status {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 12px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
}

.read-status.read {
    color: var(--success-color);
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.2);
}

.read-status.partial {
    color: var(--warning-color);
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.2);
}

/* Typing Indicator Container (above upload button) */
.typing-indicator-container {
    position: absolute;
    bottom: calc(100% - 5px);
    left: 18px;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    animation: slideIn 0.3s ease-out;
    margin-bottom: var(--spacing-xs);
}

.typing-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: none;
}

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

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

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

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

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

/* Typing Indicator (old - keep for reference) */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface-color);
    border-radius: 30px;
    margin: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    animation: slideIn 0.3s ease-out;
}

.typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

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

.typing-content {
    flex: 1;
}

.typing-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: 2px;
}

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

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

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

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

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

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

/* Messages */
#chatConversation.active {
    display: flex !important;
    flex-direction: column;
    height: 100%;
    zoom: 1; /* Reset any zoom */
    transform: scale(1); /* Reset any transform scaling */
}

/* Hide nav bar when messages page is active */
.bottom-nav.hidden {
    display: none !important;
}

.messages-container {
    flex: 1;
    overflow-y: hidden; /* Disable vertical scrolling */
    overflow-x: auto; /* Allow horizontal scrolling */
    -webkit-overflow-scrolling: touch;
    margin-bottom: calc(102px + env(safe-area-inset-bottom, 20px));
}

/* Tablet and up */
@media (min-width: 481px) {
    .messages-container {
        margin-bottom: calc(102px + env(safe-area-inset-bottom, 20px));
        overflow-y: hidden; /* Disable vertical scrolling */
        overflow-x: auto; /* Allow horizontal scrolling */
    }
}

/* Desktop and up */
@media (min-width: 769px) {
    .messages-container {
        margin-bottom: calc(102px + env(safe-area-inset-bottom, 20px));
        overflow-y: hidden; /* Disable vertical scrolling */
        overflow-x: auto; /* Allow horizontal scrolling */
    }
}

/* Mobile adjustments for messages container viewport */
@media (max-width: 480px) {
    .messages-container {
        margin-bottom: calc(92px + env(safe-area-inset-bottom, 20px));
        overflow-y: hidden; /* Disable vertical scrolling */
        overflow-x: auto; /* Allow horizontal scrolling */
    }
}

@media (max-width: 480px) {
    .message-bubble {
        max-width: 80%; /* Increased from 85% to 80% for better spacing */
        padding: var(--spacing-sm) var(--spacing-md);
    }
}
    
    .sender-name {
        font-size: 13px;
    }
    
    .message-time {
        font-size: 11px;
    }
    
    .message-bubble p {
        font-size: 14px;
    }
}

.message {
    display: flex;
    margin-bottom: var(--spacing-md);
    padding: 0 var(--spacing-lg);
    align-items: flex-end;
}

.message.own {
    justify-content: flex-end;
}

.message.other {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    min-width: 250px; /* Minimum width for better appearance */
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 18px;
    position: relative;
    background: var(--surface-color);
    border: none;
    box-shadow: none;
    margin-bottom: var(--spacing-xs);
    display: flex;
    flex-direction: column;
}

/* Message header with username */
.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xs);
    gap: var(--spacing-sm);
}

.sender-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.message-time {
    font-size: 11px;
    color: var(--text-tertiary);
    margin: 0;
}

/* Message Context Menu - Small Card Style (No Background Overlay) */
.message-context-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.message-context-menu-content {
    background: var(--surface-color);
    border-radius: 30px;
    padding: 20px;
    max-width: 280px;
    width: 85%;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.message-context-menu.show {
        opacity: 1;
    visibility: visible;
    }

.message-context-menu.show .message-context-menu-content {
    transform: scale(1);
}

.message-context-item {
    padding: 14px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.2s ease;
    border-radius: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    background: var(--background-color);
    text-align: center;
}

.message-context-item:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.message-context-item:last-child {
    margin-bottom: 0;
}

.message-context-item.delete {
    color: var(--error-color);
}

.message-context-item.delete:hover {
    background: rgba(255, 59, 48, 0.1);
    color: var(--error-color);
}

.message-context-item.edit {
    color: var(--primary-color);
}

.message-context-item.edit:hover {
    background: var(--primary-light);
    color: var(--primary-color);
}

.message-context-item svg {
    width: 18px;
    height: 18px;
}

/* Message Edited Indicator */
.message-edited {
    font-size: 11px;
    color: var(--text-tertiary);
    font-style: italic;
    margin-top: 4px;
}

/* Image-only messages */
.message.image-only {
    margin-bottom: var(--spacing-md);
    display: flex;
    justify-content: flex-end;
}

.message.other.image-only {
    justify-content: flex-start;
}

/* Prevent image extraction/dragging */
.message img {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

.message-image-only {
    max-width: 300px;
    max-height: 400px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message-image-only:hover {
    transform: scale(1.02);
}

@media (max-width: 480px) {
    .message-image-only {
        max-width: 250px;
        max-height: 300px;
    }
}

/* Enhanced Messages Page Styling */
.messages-container {
    background: var(--background-color);
}

.message {
    margin-bottom: var(--spacing-md);
    animation: messageSlideIn 0.3s ease-out;
}

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

.message-bubble {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    /* Removed all transitions and hover effects for smooth experience */
}

.message-header {
    margin-bottom: 8px;
}

.message.own .message-header {
    /* No border styling */
}

.message-content p {
    line-height: 1.5;
    margin: 0;
}

/* Read Receipts Enhancement */
.read-receipts {
    margin-top: 6px;
    padding-top: 4px;
}

.message.own .read-receipts {
    /* No border styling */
}

.read-status {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    background: transparent; /* Remove ugly background */
    color: var(--text-tertiary); /* Use subtle text color */
    margin-right: 4px;
    display: inline-block;
    font-weight: 500;
}

.read-status.read {
    background: transparent; /* Remove ugly background */
    color: var(--text-tertiary); /* Use subtle text color */
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.read-status.partial {
    background: var(--warning-color);
    color: white;
}

/* Status Indicators */
.status {
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

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

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

.status.offline {
    background: var(--text-tertiary);
    color: white;
}

/* Enhanced Button Styling for Different Backgrounds */
.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

.btn-secondary {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 20px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--background-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-danger {
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.3);
}

.btn-danger:hover {
    background: var(--error-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.4);
}

/* Dark mode button adjustments */
.dark-mode .btn-secondary {
    background: var(--surface-color);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.dark-mode .btn-secondary:hover {
    background: var(--surface-color);
    border-color: var(--primary-color);
}

.dark-mode .message-context-menu {
    background: transparent;
    border-color: var(--border-color);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.dark-mode .message-context-item {
    color: var(--text-secondary);
}

.dark-mode .message-context-item:hover {
    background: rgba(0, 122, 255, 0.2);
}

.dark-mode .message-context-item.delete:hover {
    background: rgba(255, 59, 48, 0.2);
}

.message-context-item.reactions {
    color: var(--primary-color);
}

/* Inline Reactions */
.reactions-picker {
    display: none;
    position: fixed;
    background: rgba(23, 23, 23, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    padding: 12px 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    width: auto;
    height: auto;
    max-width: 90vw;
}

.reactions-picker.show {
    display: block;
}

/* Animation removed */

.reactions-picker-grid {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: nowrap;
    align-items: center;
    min-width: 200px;
}

.reaction-picker-btn {
    background: transparent;
    border: none;
    border-radius: 50%;
    padding: 8px;
    font-size: 28px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.reaction-picker-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.15);
}

.reaction-picker-btn:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.9);
}


/* Responsive reactions picker */
@media (max-width: 480px) {
    .reactions-picker {
        padding: 10px 14px;
        border-radius: 20px;
        max-width: 95vw;
    }
    
    .reactions-picker-grid {
        gap: 6px;
        min-width: 180px;
    }
    
    .reaction-picker-btn {
        width: 40px;
        height: 40px;
        font-size: 24px;
        padding: 6px;
    }
}

/* Image Messages */
.image-message {
    margin-bottom: 4px;
}

.message-image-portrait {
    max-width: 200px;
    max-height: 300px;
    border-radius: 12px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message-image-portrait:hover {
    transform: scale(1.02);
}

.message.own .message-image-portrait {
    margin-left: auto;
    display: block;
}

.message.other .message-image-portrait {
    margin-right: auto;
    display: block;
}

/* Message Reactions */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    padding: 0; /* Remove padding */
    width: 100%;
    max-width: 250px; /* Match message bubble width */
    background: transparent; /* Remove background */
    border-radius: 0; /* Remove border radius */
    align-items: center;
}

.reaction {
    background: transparent;
    border: none;
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.reaction:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.reaction:active {
    transform: scale(0.95);
}

/* Dark mode for reactions */
.dark-mode .reaction {
    background: var(--surface-color);
    border-color: var(--border-color);
}

.dark-mode .reaction:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* Edit Mode Styling */
.message-input[data-editing-message-id] {
    border: 2px solid var(--primary-color);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.send-btn[data-editing] {
    background: var(--primary-color);
    color: white;
    animation: editPulse 2s infinite;
}

@keyframes editPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(0, 122, 255, 0);
    }
}

/* Dark mode modal adjustments */
.dark-mode .modal-overlay {
    background: rgba(0, 0, 0, 0.8);
}

.dark-mode .group-chat-modal,
.dark-mode .chat-details-modal {
    background: var(--surface-color);
    border-color: var(--border-color);
}

.dark-mode .modal-header,
.dark-mode .modal-footer {
    border-color: var(--border-color);
}

.dark-mode .modal-header h2 {
    color: var(--text-secondary);
}

.dark-mode .modal-close-btn {
    color: var(--primary-color);
}

.dark-mode .modal-close-btn:hover {
    background: var(--surface-color);
    color: var(--primary-color);
}

.dark-mode .chat-info-section {
    background: var(--background-color);
    border-color: var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Z-Index Layering System */
/* Base content: 1-99 */
/* Dropdowns and tooltips: 100-999 */
/* Modals and overlays: 1000-2999 */
/* Context menus and popups: 3000+ */

/* Ensure all modals use consistent z-index */
.modal-overlay {
    z-index: 2000;
}

.message-context-menu {
    z-index: 3000;
}

/* Toast notifications should be above everything */
.error-toast,
.success-toast {
    z-index: 4000;
}

/* Ensure consistent modal behavior */
.modal-overlay.show {
    display: flex;
}

.modal-overlay.hide {
    display: none;
}

/* Call Modal Styling - Full Screen Video Call */
.call-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--background-color);
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

/* Top Controls */
.call-top-controls {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 20px;
    z-index: 10;
}

.call-top-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.call-top-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

/* Main Video Container */
.video-container {
    position: relative;
    width: 100%;
    height: 100vh;
    background: var(--background-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

#remoteVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#localVideo {
    position: absolute;
    bottom: 120px;
    left: 20px;
    width: 90px;
    height: 120px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
    z-index: 10;
    background: var(--background-color);
}

/* Bottom Controls */
.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 30px 20px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    z-index: 10;
}

.call-control-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.call-control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.call-control-btn.end-call {
    background: var(--error-color);
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.call-control-btn.end-call:hover {
    background: var(--error-color);
}

.call-control-btn.active {
    background: var(--primary-color);
}

.call-control-btn.active svg {
    opacity: 0.7;
}

.call-control-btn.muted {
    background: var(--warning-color) !important;
    color: #000 !important;
}

.call-control-btn.muted:hover {
    background: var(--warning-color) !important;
}

.audio-control-btn.muted {
    background: var(--warning-color) !important;
    color: #000 !important;
}

.audio-control-btn.muted:hover {
    background: var(--warning-color) !important;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .call-top-controls {
        padding: 15px;
    }
    
    .call-top-btn {
        width: 44px;
        height: 44px;
    }
    
    #localVideo {
        width: 75px;
        height: 100px;
        bottom: 100px;
        left: 15px;
    }
    
    .video-controls {
        gap: 30px;
        padding: 20px 15px;
    }
    
    .call-control-btn {
        width: 56px;
        height: 56px;
    }
}

/* Audio Call Modal Styling */
.audio-call-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.audio-call-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.call-user-display {
    text-align: center;
    color: white;
}

.audio-call-avatar {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid rgba(255, 255, 255, 0.3);
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.audio-call-avatar:empty {
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 80px;
    color: rgba(255, 255, 255, 0.7);
}

.call-user-display h2 {
    margin: 0 0 10px 0;
    font-size: 32px;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.audio-call-status {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 400;
}

.audio-controls {
    display: flex;
    justify-content: center;
    gap: 60px;
    padding: 40px 20px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.3));
}

.audio-control-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.audio-control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.audio-control-btn.end-call {
    background: var(--error-color);
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.audio-control-btn.end-call:hover {
    background: var(--error-color);
}

.audio-control-btn.active {
    background: var(--primary-color);
}

.audio-control-btn.active svg {
    opacity: 0.7;
}

/* Mobile adjustments for audio call */
@media (max-width: 480px) {
    .audio-call-avatar {
        width: 150px;
        height: 150px;
        margin-bottom: 20px;
    }
    
    .audio-call-avatar:empty {
        font-size: 60px;
    }
    
    .call-user-display h2 {
        font-size: 24px;
    }
    
    .audio-call-status {
        font-size: 16px;
    }
    
    .audio-controls {
        gap: 50px;
        padding: 30px 15px;
    }
    
    .audio-control-btn {
        width: 60px;
        height: 60px;
    }
}

/* Mobile responsive modal adjustments */
@media (max-width: 768px) {
    .group-chat-modal,
    .chat-details-modal {
        width: 95%;
        margin: 20px;
        max-height: 85vh;
    }
    
    .modal-header {
        padding: 16px 20px 12px;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .modal-footer {
        padding: 12px 20px 16px;
        gap: 8px;
    }
    
    .modal-footer button {
        padding: 10px 16px;
        font-size: 13px;
    }
}

.message.own .message-bubble {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    margin-left: auto;
}

.message.other .message-bubble {
    background: var(--surface-color);
    color: var(--text-primary);
    border-color: var(--border-color);
    margin-right: auto;
}

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

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

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

.message.other .sender-name {
    color: var(--text-primary);
}

.message-time {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 400;
}

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

.message.other .message-time {
    color: var(--text-tertiary);
}

.message-content {
    margin: 0;
}

.message-bubble p {
    margin: 0;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.4;
    white-space: normal;
    word-wrap: break-word;
    color: var(--text-primary);
}

.message.own .message-bubble p {
    color: white;
}

.message.other .message-bubble p {
    color: var(--text-primary);
}

/* Read receipts */
.read-receipts {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--spacing-xs);
    align-items: center;
    gap: var(--spacing-xs);
}

.read-receipts svg {
    width: 12px;
    height: 12px;
    color: white;
}

.message-image {
    margin-bottom: var(--spacing-sm);
}

.message-image img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--spacing-sm);
    object-fit: cover;
    cursor: pointer;
    transition: var(--transition-fast);
}

.message-image img:hover {
    transform: scale(1.02);
}

.message-time {
    font-size: var(--font-size-xs);
    opacity: 0.7;
    margin-top: var(--spacing-xs);
    display: block;
}

.message-reactions {
    display: flex;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-xs);
}

.reaction {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 30px;
    padding: 2px 6px;
    font-size: var(--font-size-xs);
    display: flex;
    align-items: center;
    gap: 2px;
}

.message.own .reaction {
    background: rgba(255, 255, 255, 0.2);
}

.message-status {
    font-size: var(--font-size-xs);
    opacity: 0.7;
    margin-top: var(--spacing-xs);
    text-align: right;
}

/* Message Input */
.message-input {
    display: flex;
    align-items: center;   /* centers send button with text field */
    padding: 8px;
    background: #000;     /* black background for whole field */
    border-top: 1px solid #262626;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 20px));
    flex-shrink: 0;
    z-index: 1000;
    margin-bottom: 0;
    overflow: visible; /* Allow media menu to extend beyond bounds */
    width: 100%;
}

.message-input-field {
    flex: 1;               /* lets text area take full width */
    display: flex;
    position: relative;
    background: #1f1f1f;   /* dark gray background */
    border-radius: 25px;   /* rounded input field */
    padding: 8px 12px;
    align-items: center;
}

@media (max-width: 480px) {
    .message-input {
        padding: var(--spacing-sm);
        padding-bottom: calc(var(--spacing-sm) + 18px);
        gap: var(--spacing-xs);
        min-height: 56px;
    }
}

.input-action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.input-action-btn:hover {
    background: transparent;
    color: var(--text-secondary);
}

.message-input-field {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    min-height: 40px;
}

#messageInput {
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    font-size: 15px;
    background: transparent;
    color: #fff;
    padding: 0 40px 0 0;  /* right padding to avoid overlap with send button */
    font-family: inherit;
    line-height: 1.4;
    max-height: 120px;
    overflow-y: hidden;
    margin: 0;
    vertical-align: top;
    box-sizing: border-box;
}

.message-input textarea:focus {
    border-color: var(--primary-color);
    background: rgba(23, 23, 23, 0.5);
}

.message-input-field .send-btn {
    position: absolute;
    right: 8px;
    top: calc(50% - 22px);
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    z-index: 1;
}

.message-input-field .send-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.message-input-field .send-btn svg {
    color: var(--primary-color);
}

/* Plus Button */
.plus-btn {
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

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

.plus-btn.active {
    background: var(--primary-hover);
    transform: rotate(45deg);
}

/* Expandable Media Menu */
.media-menu {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0;
    background: transparent;
    border: none;
    margin-bottom: 0;
    animation: slideDown 0.2s ease-out;
    position: relative;
    height: 40px; /* Match the height of the plus button */
    margin-right: var(--spacing-sm);
}

.media-option {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.media-option:hover {
    background: var(--border-color);
    transform: scale(1.05);
}

.media-option#voiceMessageBtn {
    background: var(--error-color);
    color: white;
    border: 1px solid var(--error-color);
}

.media-option#voiceMessageBtn:hover {
    background: #d32f2f;
    transform: scale(1.05);
}

.media-option svg {
    width: 20px;
    height: 20px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Voice Recording Interface - Mobile optimized */
.voice-recording-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--background-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    border-top: 1px solid var(--border-color);
    min-height: 80px;
}

.voice-recording-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    width: 100%;
    max-width: 100%;
}

.voice-message-bar {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1;
    height: 40px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0 var(--spacing-md);
    position: relative;
}

.recording-indicator {
    width: 8px;
    height: 8px;
    background: var(--error-color);
    border-radius: var(--radius-full);
    animation: recordingPulse 1s ease-in-out infinite;
}

@keyframes recordingPulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

.voice-recording-timer {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    min-width: 40px;
}

.voice-waveform {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    height: 20px;
    justify-content: center;
}

.waveform-bar {
    width: 3px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: height 0.1s ease;
    min-height: 4px;
}

@keyframes waveformPulse {
    0%, 100% { 
        opacity: 0.4; 
        transform: scaleY(0.6); 
    }
    50% { 
        opacity: 1; 
        transform: scaleY(1); 
    }
}

.voice-control-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.delete-btn {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.delete-btn:hover {
    background: var(--border-color);
    transform: scale(1.05);
}

.send-btn {
    background: white;
    color: var(--text-primary);
    border: none;
}

.send-btn:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

.stop-btn {
    background: var(--error-color);
    color: white;
}

.stop-btn:hover {
    background: #d32f2f;
    transform: scale(1.05);
}

/* Voice Message Display in Chat */
.voice-message {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: #181819;
    border: none;
    border-radius: var(--radius-md);
    max-width: 300px;
    min-width: 200px;
    margin: var(--spacing-xs) 0;
}

/* Override message bubble styling for voice messages */
.message:has(.voice-message) .message-bubble {
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
}

.message:has(.voice-message) .message-header {
    display: none;
}

/* Image message display (v1.6.24) - Separate from message bubbles */
.message:has(.message-image) .message-bubble {
    display: none !important;
}

.message:has(.message-image) .message-header {
    display: none !important;
}

/* Image message container styling */
.message-image {
    max-width: 350px;
    border-radius: 20px;
    overflow: hidden;
    margin: var(--spacing-xs) 0;
    display: inline-block;
}

.message-image img {
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 20px;
    display: block;
}

/* Align image messages properly */
.message.own .message-image {
    margin-left: auto;
    margin-right: 0;
}

.message.other .message-image {
    margin-left: 0;
    margin-right: auto;
}

/* Ensure message containers are flex for image alignment */
.message:has(.message-image) {
    display: flex !important;
    align-items: flex-end !important;
}

.message.own:has(.message-image) {
    justify-content: flex-end !important;
}

.message.other:has(.message-image) {
    justify-content: flex-start !important;
}

/* Image Modal (v1.6.29) */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: var(--spacing-lg);
    box-sizing: border-box;
}

.image-modal.show {
    display: flex;
}

.image-modal-content {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 20px;
}

/* GIF Modal (v1.6.31) - iOS Style */
.gif-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: flex-end;
    z-index: 1001;
    backdrop-filter: blur(10px);
}

.gif-modal.show {
    display: flex;
    animation: gifModalSlideUp 0.3s ease-out;
}

.gif-modal-content {
    background: #1c1b1d;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
}

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

.gif-modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.gif-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

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

.gif-search-container {
    padding: var(--spacing-md) var(--spacing-lg);
}

.gif-search-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--input-background);
    color: var(--text-primary);
    font-size: var(--font-size-md);
    transition: var(--transition);
}

.gif-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.1);
}

.gif-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    padding: 10px;
    max-height: 250px;
    overflow-y: auto;
    border-top: 1px solid var(--border-color);
    background: var(--surface-color);
}

.gif-results img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.gif-results img:hover {
    transform: scale(1.05);
}

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

.voice-message-play-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--primary-color);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.voice-message-play-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.voice-message-waveform {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    height: 24px;
    justify-content: center;
}

.voice-waveform-bar {
    width: 3px;
    background: var(--text-primary);
    border-radius: 1px;
    opacity: 0.3;
    transform: scaleY(0.5);
    transition: all 0.2s ease;
    height: 12px;
}

.voice-message-duration {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    min-width: 40px;
    text-align: right;
}

@media (max-width: 480px) {
    .voice-recording-container {
        padding: var(--spacing-sm);
        max-width: 100%;
    }
    
    .voice-waveform {
        height: 36px;
        padding: 0 var(--spacing-sm);
    }
    
    .waveform-bar {
        width: 2px;
    }
    
    .voice-control-btn {
        width: 44px;
        height: 44px;
    }
    
    .voice-recording-timer {
        font-size: var(--font-size-sm);
        padding: var(--spacing-xs) var(--spacing-sm);
        min-width: 70px;
    }
    
    .voice-actions {
        padding: var(--spacing-sm);
        max-width: 100%;
    }
    
    .voice-action-btn {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: var(--font-size-xs);
    }
    
    .plus-btn {
        width: 36px;
        height: 36px;
    }
    
    .media-menu {
        gap: var(--spacing-xs);
        padding: 0;
        height: 36px; /* Match mobile plus button height */
        margin-right: var(--spacing-xs);
    }
    
    .media-option {
        width: 36px;
        height: 36px;
    }
    
    .media-option svg {
        width: 18px;
        height: 18px;
    }
    
    .media-option span {
        font-size: 9px;
        margin-top: 1px;
    }
    
    .typing-user-avatar {
        width: 36px;
        height: 36px;
    }
}

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

.send-btn:hover {
    background: var(--primary-color);
}

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

/* Search - Now uses same classes as chat page */


.search-results-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin: 0;
}

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
}

.filter-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.filter-tab:hover {
    background: transparent;
    color: var(--text-secondary);
}

.filter-tab.active {
    background: var(--primary-color);
    color: white;
}

/* Search Results */
.search-results {
    flex: 1;
    overflow-y: auto;
    background: var(--background-color);
    -webkit-overflow-scrolling: touch;
    padding: 12px 0;
}

/* Tablet and up */
@media (min-width: 481px) {
    .search-results {
        padding: 16px 0;
    }
}

/* Desktop and up */
@media (min-width: 769px) {
    .search-results {
        padding: 20px 0;
    }
}

.results-section {
    margin-bottom: var(--spacing-xl);
}

.section-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
}


.result-avatar {
    font-size: var(--text-lg);
    width: var(--component-height-lg);
    height: var(--component-height-lg);
    background: var(--surface-color);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden !important;
    position: relative;
    font-weight: 600;
}

.result-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

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

.result-name {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.result-description {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.result-status {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.result-action {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.result-action:hover {
    background: var(--primary-color);
}

/* Settings */
.profile-section {
    padding: var(--spacing-lg) var(--spacing-md);
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
}

.profile-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.profile-avatar {
    font-size: 48px;
    width: 64px;
    height: 64px;
    background: var(--surface-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-details h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.profile-details p {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin: 0;
}

.profile-actions {
    display: flex;
    gap: var(--spacing-sm);
    padding: 0 var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
}

.edit-profile-btn {
    width: 100%;
    max-width: 200px;
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: var(--font-size-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.profile-action-btn {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.settings-sections {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
}

.settings-section {
    margin-bottom: var(--spacing-xl);
}

.section-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: var(--surface-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: var(--transition);
}

.settings-item:hover {
    background: var(--surface-color);
}

.settings-item-content h4 {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.settings-item-content p {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin: 0;
}

.settings-action-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.settings-action-btn:hover {
    background: var(--primary-color);
}

.settings-action-btn.primary {
    background: var(--primary-color);
}

.settings-action-btn.danger {
    background: var(--error-color);
}

.settings-action-btn.danger:hover {
    background: var(--error-color);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.test-notification-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.test-notification-btn:hover {
    background: #0056CC;
}

.test-notification-btn:active {
    background: #004499;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: var(--transition);
    border-radius: 30px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Settings Footer */
.settings-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    background: var(--background-color);
    border-top: 1px solid var(--border-color);
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

/* ========================================
   MODERN NAVIGATION SYSTEM
   ======================================== */

/* Main Navigation Container */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    
    /* Reduced height with maintained bottom padding */
    height: calc(100px + env(safe-area-inset-bottom, 0px));
    min-height: 100px;
    
    /* Visual styling */
    background: var(--background-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgb(55 55 55 / 40%);
    
    /* Layout */
    display: flex;
    align-items: flex-start;
    justify-content: center;
    
    /* Reduced top padding, maintained bottom padding */
    padding: 10px 0;
    padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    
    /* Ensure icons are never cut off */
    box-sizing: border-box;
}

/* Navigation Items Container */
.nav-items {
    display: flex;
    align-items: center;
    justify-content: space-around;
    width: 100%;
    max-width: 400px;
    height: 100%;
    gap: 40px;
    padding-top: 5px;
    padding-bottom: 20px;
}

/* Individual Navigation Items */
.nav-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 70px;
    min-height: 70px;
    padding: 0 20px;
    border-radius: 0;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    background: transparent;
    border: none;
    outline: none;
}

/* Navigation Item States */
.nav-item:hover {
    background: transparent;
}

.nav-item.active {
    background: transparent;
}

/* Navigation Icons */
.nav-item svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: #2f2f30;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.2s ease;
    flex-shrink: 0;
}

.nav-item.active svg {
    stroke: var(--primary-color) !important;
    color: var(--primary-color) !important;
}

.nav-item:hover svg {
    stroke: var(--text-secondary);
}

/* Hide navigation in chat conversation */
.chat-conversation-active .bottom-nav {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

/* Navigation Profile Picture */
.nav-profile-picture {
    width: 28px;
    height: 28px;
    border-radius: 9999px;
    object-fit: cover;
    border: 2px solid var(--border-color);
    transition: var(--transition);
}

.nav-profile-picture:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

/* ========================================
   PROFILE PAGE STYLING
   ======================================== */

/* Profile Tab Content */
#profileTab {
    background: #000;
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Profile Header - Centered Layout */
.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #000;
    position: relative;
}

/* Profile Settings Icon Top Right */
.profile-settings-icon {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--border-radius);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-settings-icon:hover {
    background: var(--primary-light);
    color: var(--primary-color);
}


.profile-main-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}


.profile-picture img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-stats {
    display: flex;
    justify-content: space-around;
    gap: 16px;
    margin: 0;
}

.profile-stats .stat {
    text-align: center;
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

.profile-stats .stat span {
    display: block;
    font-weight: 600;
    font-size: var(--font-size-md);
}

.profile-username-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0;
}

.profile-username-row span {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.verified-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    color: white;
}

.profile-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    overflow: hidden;
}

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

.profile-details {
    margin: 0;
}

.profile-username {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    text-align: center;
    margin: 0;
}

.profile-bio {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    text-align: center;
    margin: 0;
    line-height: 1.4;
}


.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    cursor: pointer;
    transition: var(--transition);
}

.stat-item:hover {
    opacity: 0.8;
}

.stat-number {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

.profile-actions button {
    flex: 1;
    padding: 8px;
    border-radius: 6px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.edit-profile-btn {
    background: var(--primary-color);
    color: white;
    border: none;
}

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

.share-profile-btn {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.share-profile-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.profile-settings-btn {
    padding: var(--spacing-md);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Feed Tab Styles */
#feedTab.tab-content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: 100%;
    display: none;
    flex-direction: column;
}

#feedTab.tab-content.active {
    display: flex;
}


#feedTab .feed-content {
    background: #000;
    padding: 0 0 70px 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    height: 100%;
}

#feedTab .feed-post {
    background: #000;
    border-bottom: 1px solid rgb(55 55 55 / 40%);
    padding: 16px;
    margin-bottom: 0;
}

#feedTab .post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

#feedTab .post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

#feedTab .post-username {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

#feedTab .post-image {
    width: 100%;
    max-height: 400px;
    border-radius: 8px;
    margin-bottom: 12px;
    object-fit: contain;
    background: #000;
}

#feedTab .post-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

#feedTab .post-actions-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

#feedTab .action-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
}

#feedTab .action-btn:hover {
    opacity: 0.7;
}

#feedTab .action-btn svg {
    width: 20px;
    height: 20px;
}

#feedTab .action-btn.liked {
    color: #ff3040;
}

#feedTab .action-btn.liked svg {
    fill: #ff3040;
}

#feedTab .post-stats {
    margin-bottom: 8px;
    font-size: 14px;
    color: #fff;
}

#feedTab .post-stats .like-count,
#feedTab .post-stats .comment-count {
    margin-right: 16px;
    cursor: pointer;
}

#feedTab .post-stats .like-count:hover,
#feedTab .post-stats .comment-count:hover {
    opacity: 0.7;
}

#feedTab .archive-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
}

#feedTab .archive-btn:hover {
    opacity: 0.7;
}

#feedTab .archive-btn svg {
    width: 20px;
    height: 20px;
}

#feedTab .post-caption {
    font-size: 14px;
    color: #fff;
    line-height: 1.4;
}

#feedTab .post-caption .username {
    font-weight: 600;
    margin-right: 8px;
}

#feedTab .post-caption .more-text {
    color: #8E8E93;
    cursor: pointer;
    font-weight: 500;
}

#feedTab .post-caption .more-text:hover {
    color: #fff;
}

/* Likes Modal */
.likes-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.likes-modal.active {
    display: flex;
}

.likes-modal-content {
    background: #1c1c1e;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.likes-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgb(55 55 55 / 40%);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.likes-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.likes-modal-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
}

.likes-modal-close svg {
    width: 24px;
    height: 24px;
}

.likes-modal-body {
    padding: 0;
    overflow-y: auto;
    max-height: 60vh;
}

.likes-modal-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid rgb(55 55 55 / 20%);
    cursor: pointer;
}

.likes-modal-item:hover {
    background: rgb(55 55 55 / 20%);
}

.likes-modal-item:last-child {
    border-bottom: none;
}

.likes-modal-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.likes-modal-username {
    font-size: 16px;
    font-weight: 500;
    color: #fff;
}

.likes-modal-empty {
    text-align: center;
    padding: 40px 20px;
    color: #8E8E93;
    font-size: 16px;
}

/* User Profile View */
.user-profile-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #000;
}

.user-profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid rgb(55 55 55 / 40%);
    background: #000;
}

.user-profile-content {
    padding: 16px;
    background: #000;
}

      .user-profile-info {
          display: flex;
          flex-direction: column;
          align-items: flex-start;
          gap: 12px;
          margin-bottom: 20px;
      }

.user-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
}

      .user-profile-info h2 {
          margin: 0;
          font-size: 20px;
          font-weight: 700;
          color: #fff;
          text-align: left;
      }

      .user-profile-info p {
          margin: 0;
          font-size: 14px;
          color: rgba(255,255,255,.7);
          text-align: left;
      }

.user-profile-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.user-profile-actions .btn {
    flex: 1;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    border: 1px solid transparent;
}

.user-profile-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
}

.user-profile-stats .stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.user-profile-stats .stat span:first-child {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.user-profile-stats .stat span:last-child {
    font-size: 14px;
    color: rgba(255,255,255,.7);
}

/* Profile Tabs - Edge-to-Edge */
.profile-tabs {
    display: flex;
    justify-content: space-around;
    border-top: 1px solid rgb(55 55 55 / 40%);
    border-bottom: 1px solid rgb(55 55 55 / 40%);
    background: #000;
    width: 100%;
}

.profile-tab {
    flex: 1;
    padding: 14px 0;          /* remove side padding so each tab fills its third */
    background: transparent;
    border: 0;
    position: relative;
    text-align: center;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.profile-tab.active {
    color: var(--primary-color);
}

.profile-tab.active::after {
    content: "";
    position: absolute; 
    left: 0; 
    right: 0; 
    bottom: 0; 
    height: 2px;
    background: var(--primary-color);
}

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

/* Profile Feed */
/* Feed Grid - Edge-to-Edge Thumbnails */
.profile-feed { 
    padding: 8px 0 0; 
    background: #000; 
}

.feed-grid { 
    display: grid;
    grid-template-columns: repeat(3, 1fr); 
    gap: 8px; 
    padding: 8px; 
}

.grid-item {
    aspect-ratio: 3/4;
    overflow: hidden;
    background: var(--surface-color);
    border-radius: 20px;
}

.grid-item img,
.grid-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.grid-item:hover img,
.grid-item:hover video {
    transform: scale(1.05);
}

/* Following Modal */
.following-modal {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.following-modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: var(--text-lg);
    font-weight: 600;
}

.close-following-modal {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.close-following-modal:hover {
    background: var(--primary-light);
}

.following-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
}

.following-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: var(--transition);
}

.following-item:hover {
    background: var(--primary-light);
}

.following-item:last-child {
    margin-bottom: 0;
}

.following-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.following-info {
    flex: 1;
}

.following-name {
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--spacing-xs) 0;
}

.following-username {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0;
}

/* Profile Text Elements - Remove Default Margins */
.profile-info h1,
.profile-info h2,
.profile-info p {
    margin: 0;
}

/* Responsive Design */
@media (max-width: 600px) {
    .profile-header {
        padding: var(--spacing-md);
        gap: 10px;
    }
    
    .profile-avatar {
        width: 80px;
        height: 80px;
    }
    
    .profile-stats {
        width: 100%;
        justify-content: space-around;
        margin: 8px 0;
    }
    
    .profile-actions {
        width: 100%;
        gap: 8px;
    }
    
    .profile-tab {
        padding: 12px;
        font-size: var(--font-size-sm);
    }
    
    .feed-grid {
        gap: 6px;
        padding: 6px;
    }
}

/* Optional: make avatar a touch bigger on wider phones */
@media (min-width: 420px) {
    .profile-avatar {
        width: 100px;
        height: 100px;
    }
}

/* ========================================
   NEW PROFILE LAYOUT STYLES
   ======================================== */

.profile-header{
  padding: 16px 16px 8px;
  background: #000;
}

/* Top row: username left, settings right */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 10px;
  width: 100%;
}
#profileHandle{
  margin:0;
  font-weight:700;
  font-size:18px;
  color:#fff;
  text-align: left;
  flex: 1;
}
.icon-btn{
  background:transparent;
  border:0;
  width:28px; height:28px;
  display:inline-grid; place-items:center;
  border-radius:8px;
  margin-left: auto;
}

/* Second–fifth rows stacked left */
.left-stack{
  display:flex;
  flex-direction:column;
  align-items:flex-start; /* left aligned */
  gap:10px;
  width: 100%;
}

/* Profile picture directly under username */
.avatar{
  width:90px; height:90px;
  border-radius:50%;
  object-fit:cover;
}

/* Display name + bio under picture, left aligned */
.profile-details{ 
  display:flex; 
  flex-direction:column; 
  gap:4px; 
  width: 100%;
  align-items: flex-start;
}
#displayName{
  margin:0;
  font-size:20px;
  font-weight:700;
  color:#fff;
  text-align:left;
  width: 100%;
}
#bio{
  margin:0;
  font-size:14px;
  color:rgba(255,255,255,.7);
  text-align:left;
  width: 100%;
}

/* Buttons below bio */
.profile-actions{
  display:flex;
  gap:8px;
  width:100%;
  justify-content: space-between;
}
.profile-actions .btn{
  flex:1;
  padding:12px 20px;
  border-radius:10px;
  font-weight:600;
  border:1px solid transparent;
  min-width: 0;
}
.btn-primary{ background:#007AFF; color:#fff; }
.btn-ghost{ background:rgba(239,239,239,.14); color:#fff; border-color:#333; }

/* Tabs edge-to-edge */
.profile-tabs{
  display:flex;
  justify-content:space-around;
  border-top:1px solid #262626;
  border-bottom:1px solid #262626;
  background:#000;
  width:100%;
}
.profile-tab{
  flex:1;
  padding:14px 0;
  background:transparent;
  border:0;
  color:#B0B0B0;
  font-weight:600;
  position:relative;
}
.profile-tab.active{ color:#fff; }
.profile-tab.active::after{
  content:"";
  position:absolute; left:0; right:0; bottom:-1px; height:2px;
  background:#0A84FF;
}

/* Posts grid edge-to-edge */
.profile-feed{ background:#000; padding:8px 0 0; }
.feed-grid{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:2px;
  padding:0;
}
.feed-grid img{
  width:100%;
  aspect-ratio:1/1;
  object-fit:cover;
}

/* Small tweaks for larger phones */
@media (min-width:420px){
  .avatar{ width:100px; height:100px; }
  #profileHandle{ font-size:20px; }
}

/* ========================================
   REELS PAGE STYLING
   ======================================== */

.reels-container {
    position: relative;
    height: 100vh;
    overflow: hidden;
    background: #000;
}

.reels-feed {
    height: 100vh;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

.reel-item {
    position: relative;
    height: 100vh;
    width: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    flex-direction: column;
    background: #000;
}

.reel-video {
    width: 100%;
    height: calc(100vh - 80px); /* Subtract nav bar height */
    object-fit: cover;
    background: #000;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.reel-video::-webkit-media-controls {
    display: none !important;
}

.reel-video::-webkit-media-controls-panel {
    display: none !important;
}

.reel-video::-webkit-media-controls-play-button {
    display: none !important;
}

.reel-video::-webkit-media-controls-timeline {
    display: none !important;
}

.reel-video::-webkit-media-controls-current-time-display {
    display: none !important;
}

.reel-video::-webkit-media-controls-time-remaining-display {
    display: none !important;
}

.reel-video::-webkit-media-controls-mute-button {
    display: none !important;
}

.reel-video::-webkit-media-controls-volume-slider {
    display: none !important;
}

.reel-video::-webkit-media-controls-fullscreen-button {
    display: none !important;
}

.reel-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.reel-overlay > * {
    pointer-events: auto;
}

/* Top overlay - Logo only */
.reel-top-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: var(--spacing-lg);
    z-index: 20;
}

.reel-logo {
    color: white;
    font-size: 18px;
    font-weight: bold;
}

/* Right side overlay - Action buttons */
.reel-actions {
    position: absolute;
    right: var(--spacing-md);
    bottom: 120px;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    z-index: 20;
}

.reel-action-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.reel-action-btn:hover {
    transform: scale(1.05);
}

.reel-action-btn svg {
    width: 28px;
    height: 28px;
    margin-bottom: 2px;
}

.reel-action-count {
    color: white;
    font-size: 12px;
    text-align: center;
    font-weight: 500;
    line-height: 1;
}

.reel-action-label {
    color: white;
    font-size: 12px;
    text-align: center;
    margin-top: 2px;
    font-weight: 500;
}

/* Swipeable Progress Bar */
.reel-progress-container {
    position: absolute;
    bottom: 80px;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    z-index: 25;
    cursor: pointer;
}

.reel-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    z-index: 30;
}

.reel-progress-fill {
    height: 100%;
    background: white;
    width: 0%;
    transition: width 0.1s linear;
}

.reel-progress-scrubber {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
    cursor: grab;
}

.reel-progress-container:hover .reel-progress-scrubber {
    opacity: 1;
}

.reel-progress-scrubber:active {
    cursor: grabbing;
}

/* Bottom overlay - User info and caption */
.reel-bottom-overlay {
    position: absolute;
    bottom: 80px; /* Above nav bar */
    left: 0;
    right: 0;
    padding: var(--spacing-lg);
    z-index: 20;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    padding-top: 40px;
}

.reel-user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.reel-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
}

.reel-user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.reel-user-name {
    color: white;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.reel-verified-badge {
    width: 16px;
    height: 16px;
    background: #1da1f2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reel-verified-badge svg {
    width: 10px;
    height: 10px;
    color: white;
}

.reel-caption {
    color: white;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: var(--spacing-sm);
}

.reel-time {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

/* Video progress bar */
.reel-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    z-index: 30;
}

.reel-progress-fill {
    height: 100%;
    background: white;
    width: 0%;
    transition: width 0.1s linear;
}

.reel-time-display {
    position: absolute;
    bottom: 8px;
    right: var(--spacing-md);
    color: white;
    font-size: 12px;
    font-weight: 500;
    z-index: 30;
}

/* Loading state */
.reel-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: white;
    font-size: 16px;
}

.reel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: white;
    text-align: center;
    padding: var(--spacing-lg);
}

.reel-empty-icon {
    width: 64px;
    height: 64px;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.reel-empty-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.reel-empty-subtitle {
    font-size: 14px;
    opacity: 0.7;
    margin-bottom: var(--spacing-lg);
}

.reel-empty-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reel-empty-btn:hover {
    background: var(--primary-hover);
}

/* iOS-specific adjustments */
@supports (-webkit-touch-callout: none) {
    .reel-video {
        height: calc(100vh - 80px);
        position: absolute;
        top: 0;
        left: 0;
        z-index: 1;
    }
    
    .reel-item {
        height: 100vh;
        position: relative;
    }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .reel-actions {
        right: var(--spacing-sm);
        bottom: 100px;
    }
    
    .reel-action-btn {
        width: 60px;
        height: 60px;
    }
    
    .reel-action-btn svg {
        width: 28px;
        height: 28px;
    }
    
    .reel-bottom-overlay {
        padding: var(--spacing-md);
        bottom: 80px;
    }
    
    .reel-time-display {
        right: var(--spacing-sm);
    }
    
    .reel-video-controls {
        gap: var(--spacing-md);
    }
    
    .reel-control-btn {
        width: 45px;
        height: 45px;
    }
    
    .reel-play-btn {
        width: 65px;
        height: 65px;
    }
}

/* ========================================
   UPLOAD TAB STYLING (MULTI-STEP)
   ======================================== */

.upload-page {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #000;
    color: white;
}

.upload-steps {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.upload-step {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.upload-step.active {
    display: flex;
}

.step-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid rgb(55 55 55 / 40%);
    background: #000;
}

.step-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.step-spacer {
    width: 40px; /* Same width as back button for centering */
}

.back-btn, .next-btn, .post-btn {
    width: 40px;
        height: 40px;
    border-radius: 20%;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.next-btn, .post-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    min-width: 60px;
    width: auto;
    padding: 0 var(--spacing-md);
}

.back-btn:hover {
    background: var(--surface-color);
    transform: scale(1.05);
}

.next-btn:hover, .post-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

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

/* Crop/Trim Controls */
.crop-trim-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--spacing-lg);
}

.media-preview {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-lg);
    overflow: hidden;
}

.preview-media {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.crop-controls, .trim-controls {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
}

.aspect-ratio-buttons {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.aspect-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.aspect-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.aspect-btn:hover {
    background: var(--primary-hover);
    color: white;
}

.crop-slider, .trim-slider {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.crop-slider label, .trim-slider label {
    color: var(--text-primary);
    font-weight: 500;
}

.crop-slider input, .trim-slider input {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.crop-slider input::-webkit-slider-thumb, .trim-slider input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.trim-info {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

/* Preview Step */
.preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--spacing-lg);
}

.preview-media {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-lg);
    overflow: hidden;
}

.preview-details {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
}

.preview-caption {
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    white-space: pre-wrap;
}

.preview-tags {
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
}

.preview-location {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.upload-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.upload-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.back-btn {
    background: #1c1c1e;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    transition: background-color 0.2s ease;
}

.back-btn:hover {
    background: var(--surface-color);
}

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

.upload-settings-btn:hover {
    background: var(--surface-color);
}

.upload-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
}

.upload-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-xl);
    text-align: center;
    background: var(--surface-color);
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: var(--spacing-lg);
}

.upload-dropzone:hover {
    border-color: var(--primary-color);
    background: rgba(var(--primary-color-rgb), 0.1);
}

.upload-dropzone.dragover {
    border-color: var(--primary-color);
    background: rgba(var(--primary-color-rgb), 0.2);
    transform: scale(1.02);
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

.dropzone-icon {
    width: 64px;
    height: 64px;
    color: var(--text-secondary);
}

.dropzone-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.dropzone-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.dropzone-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.upload-preview {
    margin-bottom: var(--spacing-lg);
}

.preview-container {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--surface-color);
}

.preview-media {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    display: block;
}

.remove-preview-btn {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.remove-preview-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.upload-caption {
    background: #000000;
    border-radius: var(--border-radius);
    padding: var(--spacing-xs);
}

.caption-input-container {
    position: relative;
}

.caption-input-container textarea {
    width: 100%;
    min-height: 120px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.5;
    resize: vertical;
    font-family: inherit;
}

.caption-input-container textarea:focus {
    outline: none;
}

.caption-input-container textarea::placeholder {
    color: var(--text-secondary);
}

.caption-counter {
    position: absolute;
    bottom: var(--spacing-sm);
    right: var(--spacing-sm);
    font-size: 12px;
    color: var(--text-secondary);
}

.upload-tagging {
    background: #000000;
    border-radius: var(--border-radius);
    padding: var(--spacing-xs);
}

.tag-search-container {
    position: relative;
    margin-bottom: var(--spacing-md);
}

.tag-search-container input {
    width: 100%;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm);
    color: var(--text-primary);
    font-size: 14px;
}

.tag-search-container input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.tag-search-results {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-top: 1px;
    border-radius: var(--border-radius) var(--border-radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: none;
}

.tag-search-result {
    padding: var(--spacing-sm);
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.tag-search-result:hover {
    background: var(--background-color);
}

.tag-search-result:last-child {
    border-bottom: none;
}

.tag-search-result img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.tag-search-result span {
    font-size: 14px;
    color: var(--text-primary);
}

.tagged-users {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.tag-chip {
    background: var(--primary-color);
    color: white;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.tag-chip button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    margin-left: var(--spacing-xs);
}

.upload-location {
    background: #000;
    border-radius: var(--border-radius);
    padding: var(--spacing-xs);
}

.upload-location input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
}

.upload-location input:focus {
    outline: none;
}

.upload-location input::placeholder {
    color: var(--text-secondary);
}

.upload-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    background: var(--surface-color);
    position: sticky;
    bottom: 0;
}

.upload-post-btn {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.upload-post-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.upload-post-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

.btn-spinner {
    animation: spin 1s linear infinite;
}

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

/* Responsive adjustments */
@media (max-width: 480px) {
    .upload-header {
        padding: var(--spacing-md);
    }
    
    .upload-content {
        padding: var(--spacing-md);
    }
    
    .upload-footer {
        padding: var(--spacing-md);
    }
    
    .dropzone-icon {
        width: 48px;
        height: 48px;
    }
    
    .dropzone-title {
        font-size: 18px;
    }
}

/* ========================================
   POST UPLOAD MODAL STYLING (LEGACY - REMOVED)
   ======================================== */

/* Upload Modal */
.upload-modal {
    background: #000000;
    border-radius: var(--border-radius);
    width: 95%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

/* Upload Header */
.upload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.upload-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.upload-close-btn,
.upload-options-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-close-btn:hover,
.upload-options-btn:hover {
    background: var(--primary-light);
    color: var(--primary-color);
}

/* Upload Content */
.upload-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
    -webkit-overflow-scrolling: touch;
}

/* Upload Dropzone */
.upload-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-xl);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--surface-color);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.upload-dropzone:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.upload-dropzone.touch-active {
    border-color: var(--primary-color);
    background: var(--primary-light);
    transform: scale(0.98);
}

.upload-dropzone.dragover {
    border-color: var(--primary-color);
    background: var(--primary-light);
    transform: scale(1.02);
}

.upload-placeholder svg {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.upload-placeholder h3 {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--spacing-sm) 0;
}

.upload-placeholder p {
    font-size: var(--text-md);
    color: var(--text-secondary);
    margin: 0;
}

/* Upload Preview */
.upload-preview {
    margin-bottom: var(--spacing-lg);
}

.preview-container {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: #000000;
    margin-bottom: var(--spacing-md);
}

.preview-container img,
.preview-container video {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    display: block;
}

.preview-remove-btn {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-remove-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* Crop Controls */
.crop-controls {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.aspect-ratio-buttons {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.aspect-btn {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: var(--text-sm);
    font-weight: 500;
}

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

.aspect-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.crop-slider {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.crop-slider label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    min-width: 40px;
}

.crop-slider input[type="range"] {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.crop-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.crop-slider input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Caption Section */
.upload-caption {
    margin-bottom: var(--spacing-lg);
}

.caption-input-container {
    position: relative;
}

.caption-input-container textarea {
    width: 100%;
    min-height: 100px;
    padding: var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: var(--text-md);
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: var(--transition);
}

.caption-input-container textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.caption-input-container textarea::placeholder {
    color: var(--text-tertiary);
}

.caption-counter {
    position: absolute;
    bottom: var(--spacing-sm);
    right: var(--spacing-sm);
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    background: var(--surface-color);
    padding: var(--spacing-xs);
    border-radius: var(--border-radius);
}

/* Tagging Section */
.upload-tagging {
    margin-bottom: var(--spacing-lg);
}

.tag-search-container {
    position: relative;
    margin-bottom: var(--spacing-md);
}

.tag-search-container input {
    width: 100%;
    padding: var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: var(--text-md);
    outline: none;
    transition: var(--transition);
}

.tag-search-container input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.tag-search-container input::placeholder {
    color: var(--text-tertiary);
}

.tag-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: none;
}

.tag-search-result {
    padding: var(--spacing-md);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.tag-search-result:hover {
    background: var(--primary-light);
}

.tag-search-result img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.tag-search-result-info {
    flex: 1;
}

.tag-search-result-name {
    font-size: var(--text-md);
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.tag-search-result-username {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0;
}

/* Tagged Users */
.tagged-users {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.tag-chip {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: var(--primary-color);
    color: white;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius);
    font-size: var(--text-sm);
}

.tag-chip img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.tag-chip-remove {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    margin-left: var(--spacing-xs);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tag-chip-remove:hover {
    opacity: 0.8;
}

/* Location Section */
.upload-location {
    margin-bottom: var(--spacing-lg);
}

.upload-location input {
    width: 100%;
    padding: var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: var(--text-md);
    outline: none;
    transition: var(--transition);
}

.upload-location input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.upload-location input::placeholder {
    color: var(--text-tertiary);
}

/* Upload Footer */
.upload-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.upload-post-btn {
    width: 100%;
    padding: var(--spacing-md);
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: var(--text-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    position: relative;
}

.upload-post-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.upload-post-btn:disabled {
    background: var(--text-tertiary);
    cursor: not-allowed;
    transform: none;
}

.btn-spinner {
    animation: spin 1s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 480px) {
    .upload-modal {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .upload-header {
        padding: var(--spacing-md);
    }
    
    .upload-content {
        padding: var(--spacing-md);
    }
    
    .upload-footer {
        padding: var(--spacing-md);
    }
    
    .aspect-ratio-buttons {
        flex-wrap: wrap;
    }
    
    .aspect-btn {
        min-width: 60px;
    }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .bottom-nav {
        height: calc(90px + env(safe-area-inset-bottom, 0px));
        min-height: 90px;
        padding: 8px 0;
        padding-bottom: calc(25px + env(safe-area-inset-bottom, 0px));
    }
    
    .nav-items {
        gap: 30px;
        padding-top: 3px;
        padding-bottom: 15px;
    }
    
    .nav-item {
        height: 60px;
        min-height: 60px;
        padding: 0 15px;
    }
    
    .nav-item svg {
        width: 26px;
        height: 26px;
    }
    }
}

@media (min-width: 481px) {
    .bottom-nav {
        height: calc(64px + env(safe-area-inset-bottom, 0px));
        min-height: 64px;
        padding: 10px 0;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
    
    .nav-item {
        height: 48px;
        min-height: 48px;
        padding: 10px 16px;
    }
    
    .nav-item svg {
        width: 26px;
        height: 26px;
    }
}

/* Custom WebKit Scrollbar Styling for Safari PWA */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--surface-color);
}

::-webkit-scrollbar-corner {
    background: var(--surface-color);
}

/* Firefox scrollbar styling */
* {
    scrollbar-width: thin;
    scrollbar-color: #171717 #171717;
}

/* Prevent any other scrolling */
* {
    -webkit-overflow-scrolling: touch;
}

/* Call Invitation Modal */
.call-invitation-modal {
    background: var(--background-color);
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.call-invitation-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.caller-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.caller-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-color);
}

.caller-info h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.caller-info p {
    margin: 0;
    font-size: 16px;
    color: var(--text-secondary);
}

.call-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn-decline,
.btn-accept {
    padding: 12px 24px;
    border-radius: 30px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.btn-decline {
    background: var(--error-color);
    color: white;
}

.btn-decline:hover {
    background: var(--error-color);
    transform: scale(1.05);
}

.btn-accept {
    background: var(--primary-color);
    color: white;
}

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

/* Mobile adjustments for call invitation */
@media (max-width: 480px) {
    .call-invitation-modal {
        padding: 20px;
        margin: 20px;
    }
    
    .caller-avatar {
        width: 60px;
        height: 60px;
    }
    
    .caller-info h3 {
        font-size: 20px;
    }
    
    .caller-info p {
        font-size: 14px;
    }
    
    .call-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-decline,
    .btn-accept {
        width: 100%;
        padding: 15px;
    }
}

/* Media Permission Warning */
.media-permission-warning {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ff6b35;
    color: white;
    z-index: 10000;
    padding: 12px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.warning-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    gap: 15px;
}

.warning-content span {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.permission-btn {
    background: white;
    color: #ff6b35;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.permission-btn:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

.close-btn {
    background: var(--surface-color);
    border: none;
    color: var(--primary-color);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-btn:hover {
    background: var(--surface-color);
    border-radius: 50%;
}

/* Mobile adjustments for permission warning */
@media (max-width: 480px) {
    .warning-content {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .warning-content span {
        font-size: 13px;
    }
    
    .permission-btn {
        width: 100%;
        padding: 10px;
    }
}

@media (max-width: 480px) {
    /* Bottom nav padding handled by main .bottom-nav rule */
}

/* Old nav-item styles removed - using new modern system above */

/* Old bottom-nav button styles removed - using new modern system above */

.content-area {
    box-sizing: border-box;
}

/* Responsive Design */
@media (max-width: 768px) {
    .content-area {
        padding-bottom: 0;
    }
    
    .page-header {
        padding: var(--spacing-md);
    }
    
    .chat-list {
        padding: 0;
    }
    
    .search-results {
        padding: 0;
    }
    
    .chat-item {
        padding: var(--spacing-md);
    }
    
    .result-item {
        padding: var(--spacing-md);
    }
    
    .messages-container {
        padding: 0; /* Remove conflicting padding */
    }
    
    .message-input {
        padding: var(--spacing-md);
    }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.screen.active {
    animation: fadeIn 0.3s ease-out;
}

/* Remove focus styles */
/* Remove all focus outlines globally */
*:focus {
    outline: none !important;
    box-shadow: none !important;
}

button:focus,
input:focus,
textarea:focus,
select:focus,
.nav-item:focus,
.chat-item:focus,
.settings-item:focus,
.result-item:focus,
.action-btn:focus,
.call-btn:focus {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* Touch targets */
button,
.nav-item,
.chat-item,
.settings-item {
    min-height: 44px;
    min-width: 44px;
}

/* Light mode specific overrides */
:not(.dark-mode) .chat-item {
    border-bottom-color: rgba(55, 55, 55, 0.40);
}

:not(.dark-mode) .chat-search-input {
    background: #000;
}

:not(.dark-mode) .chat-search-input:focus {
    background: var(--surface-color);
}

:not(.dark-mode) .chat-avatar {
    background: #e0e0e0;
    color: #666;
}

:not(.dark-mode) .unread-badge {
    background: var(--primary-color);
    color: white;
}

:not(.dark-mode) .read-receipt {
    background: #999;
}

:not(.dark-mode) .read-receipt.read {
    background: var(--primary-color);
}

/* Hide OneSignal UI elements completely */
#onesignal-bell-container,
#onesignal-slidedown-container,
#onesignal-fullscreen-container,
.onesignal-bell-launcher,
.onesignal-slidedown-container,
.onesignal-fullscreen-container,
[data-onesignal-id],
.onesignal-bell-svg,
.onesignal-bell-launcher-button,
.onesignal-bell-launcher-button svg,
.onesignal-bell-launcher-button *,
.onesignal-bell-launcher * {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Fix zoom and viewport issues */
html, body {
    height: 100%;
    overflow: hidden;
    zoom: 1; /* Reset any zoom */
    transform: scale(1); /* Reset any transform scaling */
}

#chatListContent,
.search-results,
.settings-sections {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: calc(102px + env(safe-area-inset-bottom, 20px));
}

#messagesContainer {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 0; /* No margin for messages page */
}

/* Mobile adjustments for chat list viewport */
@media (max-width: 480px) {
    #chatListContent,
    .search-results,
    .settings-sections {
        margin-bottom: calc(92px + env(safe-area-inset-bottom, 20px));
    }
}

/* Call Button Styles */
.call-btn {
    background: transparent;
    border: none;
    color: #fff;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-right: 4px; /* Reduced from 8px */
    outline: none; /* Remove focus outline */
}

.call-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    outline: none; /* Remove hover outline */
}

.call-btn:active {
    background: rgba(255, 255, 255, 0.2);
    outline: none; /* Remove active outline */
}

.call-btn:focus {
    outline: none; /* Remove focus outline */
}

/* Voice Call Interface Styles */
.voice-call-interface {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background-color);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.voice-call-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
}

.voice-call-avatar {
    width: 200px;
    height: 200px;
    border-radius: var(--radius-full);
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--spacing-xl);
    box-shadow: var(--shadow-hover);
}

.voice-call-avatar span {
    font-size: 80px;
    font-weight: 600;
    color: white;
}

.voice-call-name {
    font-size: 32px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--spacing-sm) 0;
}

.voice-call-status {
    font-size: 18px;
    color: var(--text-secondary);
    margin: 0;
}

.voice-call-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-xl);
    padding: var(--spacing-xl);
    padding-bottom: calc(var(--spacing-xl) + env(safe-area-inset-bottom, 20px));
}

.voice-control-btn {
    width: 70px;
    height: 70px;
    border-radius: var(--radius-full);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.voice-control-btn:hover {
    background: var(--border-color);
    transform: scale(1.05);
}

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

.voice-hangup-btn {
    background: var(--error-color);
    color: white;
    border: 1px solid var(--error-color);
}

.voice-hangup-btn:hover {
    background: #d32f2f;
    transform: scale(1.05);
}

/* Mobile adjustments for voice call */
@media (max-width: 480px) {
    .voice-call-avatar {
        width: 150px;
        height: 150px;
        margin-bottom: var(--spacing-lg);
    }
    
    .voice-call-avatar span {
        font-size: 60px;
    }
    
    .voice-call-name {
        font-size: 24px;
    }
    
    .voice-call-status {
        font-size: 16px;
    }
    
    .voice-control-btn {
        width: 60px;
        height: 60px;
    }
    
    .voice-call-controls {
        gap: var(--spacing-lg);
        padding: var(--spacing-lg);
        padding-bottom: calc(var(--spacing-lg) + env(safe-area-inset-bottom, 20px));
    }
}
.call-interface {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background-color);
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

.main-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: var(--background-color);
}

.pip {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 120px;
    height: 180px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--background-color);
    border: 2px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
}

.call-controls {
    position: absolute;
    bottom: 30px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 0;
}

.control-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

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

.control-btn.active {
    background: #ffa500;
}

.hangup-btn {
    background: var(--error-color);
}

.hangup-btn:hover {
    background: #ff5555;
}

.flip-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

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

/* Mobile adjustments */
@media (max-width: 480px) {
    .pip {
        width: 100px;
        height: 150px;
        bottom: 15px;
        left: 15px;
    }
    
    .call-controls {
        bottom: 20px;
        right: 15px;
        gap: 12px;
    }
    
    .control-btn {
        width: 55px;
        height: 55px;
    }
    
    .flip-btn {
        width: 45px;
        height: 45px;
        top: 15px;
        right: 15px;
    }
}

/* Call Container Styles */
.call-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background-color);
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

.call-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.call-info h3 {
    color: #fff;
    margin: 0;
    font-size: 18px;
}

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

.call-controls {
    display: flex;
    gap: 12px;
}

.call-control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    padding: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.call-control-btn.active {
    background: #ffa500;
}

.call-control-btn.end-call {
    background: var(--error-color);
}

.call-control-btn.end-call:hover {
    background: #ff5555;
}

.call-video-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
}

#remoteVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#localVideo {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.audio-only-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.audio-wave {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 20px;
}

.wave-bar {
    width: 4px;
    height: 20px;
    background: #fff;
    border-radius: 2px;
    animation: wave 1.5s ease-in-out infinite;
}

.wave-bar:nth-child(2) {
    animation-delay: 0.1s;
}

.wave-bar:nth-child(3) {
    animation-delay: 0.2s;
}

.wave-bar:nth-child(4) {
    animation-delay: 0.3s;
}

.wave-bar:nth-child(5) {
    animation-delay: 0.4s;
}

@keyframes wave {
    0%, 100% {
        height: 20px;
    }
    50% {
        height: 40px;
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .call-header {
        padding: 16px;
    }
    
    .call-controls {
        gap: 8px;
    }
    
    .call-control-btn {
        padding: 10px;
    }
    
    #localVideo {
        width: 120px;
        height: 90px;
        bottom: 16px;
        right: 16px;
    }
    
    .call-info h3 {
        font-size: 16px;
    }
    
    .call-info span {
        font-size: 12px;
    }
}

/* Permission UI Styles */
.permission-error-content,
.permission-success-content {
    text-align: center;
    padding: 20px;
}

.permission-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.permission-instructions {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    text-align: left;
}

.permission-instructions h3 {
    color: #fff;
    margin-bottom: 15px;
    font-size: 16px;
}

.permission-instructions ol {
    color: var(--text-secondary);
    margin: 0;
    padding-left: 20px;
}

.permission-instructions li {
    margin-bottom: 8px;
    line-height: 1.4;
}

.permission-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.permission-actions .btn-primary,
.permission-actions .btn-secondary {
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.permission-actions .btn-primary {
    background: var(--primary-color);
    color: white;
}

.permission-actions .btn-primary:hover {
    background: #0056CC;
}

.permission-actions .btn-secondary {
    background: var(--surface-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.permission-actions .btn-secondary:hover {
    background: var(--surface-color);
}

/* Safari PWA specific styles */
.permission-instructions.safari-pwa {
    border-color: #FF9500;
}

.permission-instructions.safari-pwa h3 {
    color: var(--warning-color);
}

/* Safari specific styles */
.permission-instructions.safari {
    border-color: #007AFF;
}

.permission-instructions.safari h3 {
    color: #007AFF;
}

/* Permission Modal Styles - REMOVED (using native browser prompts) */

/* Toast Messages */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 25px;
    border-radius: 15px;
    color: #fff;
    font-weight: 600;
    z-index: 10001;
    animation: toastSlideIn 0.3s ease-out;
}

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

.toast.error {
    background: #FF3B30;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}