/* ========================================
   CHAT2YOU - PREMIUM UI/UX DESIGN SYSTEM
   Modern, responsive chat interface
   ======================================== */

/* CSS Variables - Design System */
:root {
    /* Colors - Professional palette */
    --primary-bg: #0d1117;
    --secondary-bg: #161b22;
    --tertiary-bg: #21262d;
    --surface-bg: #30363d;
    --elevated-bg: #282e33;
    
    /* Brand Colors */
    --brand-primary: #58a6ff;
    --brand-secondary: #79c0ff;
    --brand-tertiary: #a5f3fc;
    --brand-gradient: linear-gradient(135deg, #58a6ff 0%, #79c0ff 50%, #a5f3fc 100%);
    
    /* Text Colors */
    --text-primary: #f0f6fc;
    --text-secondary: #c9d1d9;
    --text-muted: #8b949e;
    --text-accent: #58a6ff;
    
    /* Status Colors */
    --success: #238636;
    --warning: #d29922;
    --error: #da3633;
    --online: #3fb950;
    
    /* Interactive States */
    --hover-bg: rgba(177, 186, 196, 0.12);
    --active-bg: rgba(177, 186, 196, 0.2);
    --focus-ring: rgba(88, 166, 255, 0.4);
    
    /* Borders & Shadows */
    --border-subtle: #30363d;
    --border-muted: #21262d;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15), 0 10px 10px rgba(0, 0, 0, 0.04);
    
    /* Spacing Scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Typography Scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Z-Index Scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;
}

/* ========================================
   RESET & BASE STYLES
   ======================================== */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    height: 100%;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
    background: var(--primary-bg);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
    height: 100%;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection in input areas and messages */
input, textarea, .message-text, .message-bubble {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

/* ========================================
   LANDING PAGE STYLES
   ======================================== */

.landing-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--secondary-bg) 100%);
    position: relative;
    overflow: hidden;
}

.landing-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(88, 166, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(121, 192, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(165, 243, 252, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-lg);
    position: relative;
    z-index: 1;
    width: 100%;
}

/* Hero Section */
.hero-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2xl);
    min-height: 100vh;
    padding: var(--space-2xl) var(--space-xl);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.hero-content {
    flex: 1;
    max-width: 600px;
    text-align: left;
    padding-right: var(--space-2xl);
}

.hero-title {
    margin-bottom: var(--space-lg);
}

.brand-name {
    display: block;
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 800;
    background: var(--brand-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
    margin-bottom: var(--space-sm);
}

.hero-subtitle {
    display: block;
    font-size: clamp(1.25rem, 2.5vw, 1.5rem);
    color: var(--text-secondary);
    font-weight: 400;
}

.hero-description {
    font-size: var(--text-lg);
    color: var(--text-muted);
    margin-bottom: var(--space-2xl);
    line-height: 1.7;
}

/* Join Room Section */
.join-room {
    background: var(--secondary-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    max-width: 500px;
    width: 100%;
}

.room-label {
    display: block;
    font-size: var(--text-base);
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    font-weight: 500;
}

.input-group {
    display: flex;
    align-items: stretch;
    background: var(--tertiary-bg);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-normal);
    min-height: 50px;
}

.input-group:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.url-prefix {
    padding: var(--space-md) var(--space-lg);
    background: var(--surface-bg);
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 500;
    border-right: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
}

#roomInput {
    flex: 1;
    padding: var(--space-md) var(--space-lg);
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: var(--text-base);
    outline: none;
    min-width: 0;
}

#roomInput::placeholder {
    color: var(--text-muted);
}

#joinRoomBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--brand-gradient);
    color: white;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 120px;
}

#joinRoomBtn:hover {
    transform: translateX(2px);
    box-shadow: var(--shadow-md);
}

#joinRoomBtn:active {
    transform: translateX(0px);
}

/* Hero Visual */
.hero-visual {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
    width: 50%;
}

.chat-preview {
    width: 100%;
    max-width: 500px;
    perspective: 1000px;
}

.chat-window {
    background: var(--secondary-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    transform: rotateY(-5deg) rotateX(5deg);
    transition: transform var(--transition-slow);
}

.chat-window:hover {
    transform: rotateY(0deg) rotateX(0deg);
}

.chat-header-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    background: var(--tertiary-bg);
    border-bottom: 1px solid var(--border-subtle);
}

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

.chat-dots span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-muted);
}

.chat-dots span:nth-child(1) { background: #ff5f57; }
.chat-dots span:nth-child(2) { background: #ffbd2e; }
.chat-dots span:nth-child(3) { background: #28ca42; }

.room-name-preview {
    font-weight: 600;
    color: var(--text-primary);
}

.chat-messages-preview {
    padding: var(--space-lg);
    min-height: 300px;
}

.message-preview {
    margin-bottom: var(--space-md);
    animation: fadeInUp 0.5s ease;
}

.time-preview {
    color: var(--text-muted);
    font-size: var(--text-xs);
}

.nick-preview {
    color: var(--brand-primary);
    font-weight: 600;
    margin: 0 var(--space-sm);
}

.text-preview {
    color: var(--text-secondary);
}

.typing-indicator {
    color: var(--text-muted);
    font-style: italic;
    animation: pulse 1.5s infinite;
}

/* How To Section */
.how-to-section {
    text-align: center;
    padding: var(--space-2xl) 0;
}

.how-to-title {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-2xl);
}

.steps-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    margin-bottom: var(--space-2xl);
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.step {
    display: flex;
    align-items: flex-start;
    gap: var(--space-lg);
    padding: var(--space-xl);
    background: var(--secondary-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: all var(--transition-normal);
}

.step:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--brand-primary);
}

.step-number {
    width: 40px;
    height: 40px;
    background: var(--brand-gradient);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-lg);
    flex-shrink: 0;
}

.step-content {
    text-align: left;
}

.step-content h3 {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.step-content p {
    color: var(--text-muted);
    line-height: 1.6;
}

/* Popular Rooms */
.popular-rooms {
    text-align: center;
    padding: var(--space-2xl) 0;
}

.popular-title {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.popular-subtitle {
    color: var(--text-muted);
    font-size: var(--text-lg);
    margin-bottom: var(--space-2xl);
}

.room-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: var(--space-lg);
    max-width: 1000px;
    margin: 0 auto;
}

.room-card {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-xl);
    background: var(--secondary-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    transition: all var(--transition-normal);
}

.room-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand-primary);
    background: var(--tertiary-bg);
}

.room-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.room-info {
    text-align: left;
}

.room-info h3 {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.room-info p {
    color: var(--text-muted);
    font-size: var(--text-sm);
    line-height: 1.5;
}

/* ========================================
   MODERN CHAT INTERFACE STYLES
   ======================================== */

/* Chat Container */
.chat-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--primary-bg);
    position: relative;
    overflow: hidden;
    /* Ensure proper layering for sticky elements */
    isolation: isolate;
}

/* Modern Chat Header */
.chat-header-modern {
    background: var(--secondary-bg);
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--space-lg) var(--space-xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    transition: all var(--transition-normal);
    /* Enhanced visual separation when sticky */
    border-bottom-color: var(--brand-primary);
}

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

.room-avatar {
    width: 50px;
    height: 50px;
    background: var(--brand-gradient);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--shadow-md);
}

.room-emoji {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.room-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.room-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

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

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--online);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

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

.online-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--tertiary-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.online-indicator:hover {
    background: var(--surface-bg);
    border-color: var(--brand-primary);
    transform: translateY(-1px);
}

.online-dot {
    width: 6px;
    height: 6px;
    background: var(--online);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.online-count {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--brand-primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--tertiary-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    background: var(--brand-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 700;
    color: white;
    text-transform: uppercase;
}

.user-name-small {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-btn {
    width: 40px;
    height: 40px;
    background: var(--tertiary-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
}

.header-btn:hover {
    background: var(--surface-bg);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.leave-btn:hover {
    border-color: var(--error);
    color: var(--error);
    background: rgba(218, 54, 51, 0.1);
}

/* User Navbar */
.user-navbar {
    background: var(--surface-secondary);
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--space-sm) var(--space-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    position: sticky;
    top: 70px; /* Below the chat header */
    z-index: calc(var(--z-sticky) - 1);
    backdrop-filter: blur(10px);
    transition: all var(--transition-normal);
    /* Enhanced visual appearance */
    border-bottom-color: var(--brand-primary);
    background: rgba(22, 27, 34, 0.95);
}

.user-navbar .user-profile {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    background: var(--surface-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.user-navbar .user-avatar-small {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: var(--text-sm);
}

.user-navbar .user-name-small {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
}

/* Chat Main Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.messages-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages-scroll-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    padding: var(--space-xl) var(--space-2xl);
    /* Add extra right padding for reply buttons */
    padding-right: calc(var(--space-2xl) + 40px);
}

.messages-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    min-height: 100%;
    justify-content: flex-end;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Welcome Message */
.welcome-message {
    display: flex;
    align-items: flex-start;
    gap: var(--space-lg);
    padding: var(--space-xl);
    background: linear-gradient(135deg, var(--tertiary-bg) 0%, var(--surface-bg) 100%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-xl);
    position: relative;
    overflow: hidden;
}

.welcome-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--brand-gradient);
}

.welcome-avatar {
    width: 50px;
    height: 50px;
    background: var(--brand-gradient);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.welcome-content h3 {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.welcome-content p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Message Styles */
.message {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    animation: fadeInUp 0.4s ease-out;
    position: relative;
    transition: transform var(--transition-normal);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
}

.message-avatar {
    width: 40px;
    height: 40px;
    background: var(--surface-bg);
    border: 2px solid var(--brand-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--brand-primary);
    text-transform: uppercase;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

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

.message-username {
    font-weight: 700;
    color: var(--brand-primary);
    font-size: var(--text-sm);
}

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

.message-bubble {
    background: var(--secondary-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    position: relative;
    transition: all var(--transition-normal);
    max-width: 70%;
}

.message-bubble:hover {
    background: var(--tertiary-bg);
    border-color: var(--brand-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

.message-text a {
    color: var(--brand-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all var(--transition-normal);
}

.message-text a:hover {
    border-bottom-color: var(--brand-primary);
}

/* Own Messages */
.message.own {
    flex-direction: row-reverse;
}

.message.own .message-content {
    align-items: flex-end;
}

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

.message.own .message-bubble {
    background: var(--brand-gradient);
    border-color: var(--brand-primary);
    color: #1a1a1a !important;
    max-width: 70%;
}

.message.own .message-text {
    color: #1a1a1a !important;
}

.message.own .message-bubble * {
    color: #1a1a1a !important;
}

.message.own .message-text a {
    color: rgba(255, 255, 255, 0.9);
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

.message.own .message-text a:hover {
    border-bottom-color: white;
}

.message.own .message-avatar {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-secondary);
}

/* System Messages */
.message.system {
    justify-content: center;
    margin: var(--space-lg) 0;
}

.message.system .message-bubble {
    background: var(--tertiary-bg);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-full);
    padding: var(--space-sm) var(--space-lg);
    font-size: var(--text-sm);
    color: white !important;
    max-width: none;
}

.message.system .message-bubble * {
    color: white !important;
}

/* Typing Indicator */
.typing-indicator-modern {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-2xl);
    animation: fadeInUp 0.3s ease-out;
    background: rgba(88, 166, 255, 0.1);
    border-radius: var(--radius-lg);
    margin: var(--space-sm) 0;
    border-left: 3px solid var(--brand-primary);
}

.typing-avatar {
    width: 40px;
    height: 40px;
    background: var(--surface-bg);
    border: 2px solid var(--brand-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

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

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

.typing-text {
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-style: italic;
}

.typing-user {
    color: var(--brand-primary);
    font-weight: 600;
}

/* Modern Chat Footer */
.chat-footer-modern {
    background: var(--secondary-bg);
    border-top: 1px solid var(--border-subtle);
    padding: var(--space-xl) var(--space-2xl);
    backdrop-filter: blur(20px);
    position: sticky;
    bottom: 0;
    z-index: var(--z-sticky);
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.1);
    transition: all var(--transition-normal);
    /* Enhanced visual separation when sticky */
    border-top-color: var(--brand-primary);
    background: rgba(22, 27, 34, 0.95);
}

.input-area {
    max-width: 1200px;
    margin: 0 auto;
}

.input-wrapper-modern {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--tertiary-bg);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-md);
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.input-wrapper-modern:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--focus-ring), var(--shadow-md);
    transform: translateY(-2px);
}

.attachment-section {
    display: flex;
    gap: var(--space-sm);
}

.attachment-btn {
    width: 40px;
    height: 40px;
    background: var(--surface-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    flex-shrink: 0;
}

.attachment-btn:hover {
    background: var(--elevated-bg);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.attachment-btn.voice-btn:hover {
    background: rgba(88, 166, 255, 0.1);
}

.attachment-btn.voice-btn.recording {
    background: var(--error) !important;
    color: white !important;
    animation: recordingPulse 1s infinite alternate;
    box-shadow: 0 0 20px rgba(218, 54, 51, 0.5);
}

.attachment-btn.copy-link-btn:hover {
    background: rgba(88, 166, 255, 0.1);
    color: var(--brand-primary);
}

.attachment-btn.copy-link-btn:active {
    transform: scale(0.95);
}

.message-input-area {
    flex: 1;
    position: relative;
}

#messageInput {
    width: 100%;
    min-height: 40px;
    max-height: 120px;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: var(--text-base);
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    outline: none;
    overflow-y: auto;
}

#messageInput::placeholder {
    color: var(--text-muted);
}

.send-section {
    display: flex;
}

.send-btn-modern {
    width: 48px;
    height: 48px;
    background: var(--surface-bg);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    flex-shrink: 0;
    disabled: true;
}

.send-btn-modern.active {
    background: var(--brand-gradient);
    border-color: var(--brand-primary);
    color: white;
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.send-btn-modern:hover.active {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

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

.input-footer-modern {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-md);
    padding: 0 var(--space-md);
}

.char-counter-modern {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: 500;
}

.input-hints-modern {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Voice Recording Overlay */
.voice-recording-modern {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: var(--z-modal) !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    padding: var(--space-lg);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.voice-recording-modern.show {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Additional mobile improvements for voice recording */
@media (max-width: 768px) {
    .voice-recording-modern {
        padding: var(--space-md);
    }
    
    .recording-modal {
        width: 95%;
        max-width: 350px;
        padding: var(--space-xl);
    }
}

.recording-backdrop-modern {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
}

.recording-modal {
    position: relative;
    background: var(--secondary-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    animation: slideInUp var(--transition-normal);
    margin: 0 auto;
    flex-shrink: 0;
}

.recording-header h3 {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.recording-header p {
    color: var(--text-muted);
    margin-bottom: var(--space-2xl);
}

.recording-visual {
    margin-bottom: var(--space-2xl);
}

.pulse-container {
    width: 120px;
    height: 120px;
    margin: 0 auto var(--space-lg);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid var(--brand-primary);
    border-radius: 50%;
    animation: pulseRing 2s infinite;
}

.pulse-ring.ring-2 {
    animation-delay: 0.5s;
}

.pulse-ring.ring-3 {
    animation-delay: 1s;
}

.recording-icon {
    width: 60px;
    height: 60px;
    background: var(--brand-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-lg);
    animation: recordingPulse 1s infinite alternate;
}

.sound-visualizer {
    display: flex;
    justify-content: center;
    gap: var(--space-xs);
    height: 30px;
    align-items: flex-end;
}

.sound-bar {
    width: 4px;
    background: var(--brand-primary);
    border-radius: 2px;
    animation: soundWave 1s infinite ease-in-out;
}

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

.sound-waveform:hover .wave-bar {
    opacity: 1;
    background: var(--brand-secondary);
}

.sound-duration {
    font-size: var(--text-xs);
    color: var(--brand-primary);
    font-family: 'Courier New', monospace;
    font-weight: 600;
    flex-shrink: 0;
    min-width: 35px;
    text-align: right;
}

/* Legacy Modal for Nickname */
.modal {
    display: none;
    position: fixed;
    z-index: var(--z-modal);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

/* Modern Modals */
.modal-modern {
    display: none;
    position: fixed;
    z-index: var(--z-modal);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

.modal-modern.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--transition-normal);
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

/* Enhanced Nickname Modal */
.modal-content .modal-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.modal-content .modal-header h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.modal-subtitle {
    color: var(--text-secondary);
    font-size: var(--text-base);
}

.error-message {
    background: rgba(218, 54, 51, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    color: var(--error);
    font-size: var(--text-sm);
    margin-bottom: var(--space-lg);
    text-align: center;
}

.nickname-input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

#nicknameInput {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--tertiary-bg);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 16px; /* Prevent zoom on iOS */
    transition: all var(--transition-normal);
    -webkit-appearance: none;
    transform: translateZ(0);
    outline: none;
}

#nicknameInput:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

#nicknameInput::placeholder {
    color: var(--text-muted);
}

.primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    background: var(--brand-gradient);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

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

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.modal-footer {
    text-align: center;
}

.modal-footer small {
    color: var(--text-muted);
    font-style: italic;
}

/* Image Modal */
.image-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: slideInUp var(--transition-normal);
}

.close-btn-modern {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 44px;
    height: 44px;
    background: rgba(13, 17, 23, 0.9);
    border: 2px solid var(--border-subtle);
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    z-index: var(--z-tooltip);
}

.close-btn-modern:hover {
    background: rgba(218, 54, 51, 0.9);
    border-color: var(--error);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(218, 54, 51, 0.4);
}

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

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

#modalImage {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

/* User List Modal */
.user-list-modal-content {
    background: var(--secondary-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: slideInUp var(--transition-normal);
    position: relative;
}

.modal-header-modern {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header-modern h2 {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.user-list-container-modern {
    flex: 1;
    overflow-y: auto;
    margin: -var(--space-sm);
    padding: var(--space-sm);
}

.user-list-modern {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.loading-users {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-2xl);
    color: var(--text-muted);
}

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

.user-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--tertiary-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: all var(--transition-normal);
}

.user-item:hover {
    background: var(--surface-bg);
    border-color: var(--brand-primary);
    transform: translateY(-1px);
}

.user-item-avatar {
    width: 40px;
    height: 40px;
    background: var(--brand-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    position: relative;
    flex-shrink: 0;
}

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

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

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

.user-online-dot {
    width: 8px;
    height: 8px;
    background: var(--online);
    border-radius: 50%;
    position: absolute;
    top: -2px;
    right: -2px;
    border: 2px solid var(--secondary-bg);
    animation: pulse 2s infinite;
}

/* ========================================
   RESPONSIVE DESIGN FOR MODERN CHAT
   ======================================== */

/* Mobile First - Smartphones */
@media (max-width: 768px) {
    /* Fix mobile viewport issues */
    html, body {
        width: 100%;
        height: 100%;
        overflow-x: hidden;
        position: relative;
    }
    
    /* Ensure chat container takes full mobile screen */
    .chat-container {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        width: 100vw;
        max-width: 100%;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow: hidden;
    }
    
    /* Fix mobile safari bottom bar issues */
    @supports (-webkit-touch-callout: none) {
        .chat-container {
            height: -webkit-fill-available;
        }
    }
    .chat-header-modern {
        padding: var(--space-md);
        gap: var(--space-sm);
    }
    
    .header-left {
        gap: var(--space-md);
    }
    
    .room-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .room-title {
        font-size: var(--text-lg);
    }
    
    .header-right {
        gap: var(--space-sm);
    }
    
    .user-profile {
        padding: var(--space-xs) var(--space-sm);
    }
    
    .user-avatar-small {
        width: 28px;
        height: 28px;
        font-size: var(--text-xs);
    }
    
    .user-name-small {
        max-width: 80px;
    }
    
    .header-btn {
        width: 36px;
        height: 36px;
    }
    
    .messages-scroll-container {
        padding: var(--space-lg) var(--space-md);
        /* Add extra right padding for mobile reply buttons */
        padding-right: calc(var(--space-md) + 35px);
        /* Improve mobile scrolling */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        scroll-behavior: smooth;
    }
    
    /* Fix message bubbles for mobile */
    .message {
        margin-bottom: var(--space-md);
    }
    
    .welcome-message {
        padding: var(--space-lg);
        gap: var(--space-md);
    }
    
    .welcome-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
    }
    
    .message-bubble {
        max-width: 85%;
        padding: var(--space-sm) var(--space-md);
    }
    
    /* Fix responsive images for mobile */
    .message-image {
        max-width: 100% !important;
        max-height: 250px !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain;
    }
    
    .chat-footer-modern {
        padding: var(--space-md);
    }
    
    .input-wrapper-modern {
        padding: var(--space-sm);
    }
    
    /* Fix mobile input zoom issues */
    #messageInput {
        font-size: 16px !important; /* Prevent zoom on iOS */
        transform: translateZ(0); /* Force hardware acceleration */
        -webkit-appearance: none;
        border-radius: var(--radius-lg) !important;
    }
    
    .attachment-btn {
        width: 36px;
        height: 36px;
        touch-action: manipulation; /* Improve touch responsiveness */
    }
    
    .send-btn-modern {
        width: 44px;
        height: 44px;
        touch-action: manipulation;
    }
    
    .input-footer-modern {
        flex-direction: column;
        gap: var(--space-xs);
        text-align: center;
        margin-top: var(--space-sm);
    }
    
    .user-navbar {
        padding: var(--space-sm) var(--space-md);
        min-height: 36px;
        top: 60px; /* Mobile header height is smaller */
    }
    
    .user-navbar .user-profile {
        padding: var(--space-xs);
    }
    
    .user-navbar .user-avatar-small {
        width: 24px;
        height: 24px;
        font-size: var(--text-xs);
    }
    
    .user-navbar .user-name-small {
        font-size: var(--text-xs);
    }
    
    .recording-modal {
        padding: var(--space-xl);
        width: 95%;
    }
    
    .pulse-container {
        width: 100px;
        height: 100px;
    }
    
    .recording-icon {
        width: 50px;
        height: 50px;
    }
    
    .user-list-modal-content {
        width: 95%;
        max-height: 70vh;
        padding: var(--space-lg);
    }
    
    /* Improve mobile modal inputs */
    .modal #nicknameInput {
        font-size: 16px !important; /* Prevent zoom on iOS */
        -webkit-appearance: none;
        transform: translateZ(0);
    }
    
    /* Better touch targets for mobile */
    .primary-btn {
        min-height: 44px; /* Apple's recommended touch target size */
        touch-action: manipulation;
    }
    
    .header-btn {
        min-width: 44px;
        min-height: 44px;
        touch-action: manipulation;
    }
    
    .online-indicator {
        min-height: 44px;
        touch-action: manipulation;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .chat-header-modern {
        padding: var(--space-lg) var(--space-xl);
    }
    
    .messages-scroll-container {
        padding: var(--space-xl);
    }
    
    .chat-footer-modern {
        padding: var(--space-lg) var(--space-xl);
    }
}

/* Desktop */
@media (min-width: 1025px) {
    .messages-scroll-container {
        padding: var(--space-xl) var(--space-2xl);
    }
    
    .chat-footer-modern {
        padding: var(--space-xl) var(--space-2xl);
    }
}

/* ========================================
   LANDING PAGE RESPONSIVE DESIGN
   ======================================== */

/* Mobile - Stack vertically */
@media (max-width: 768px) {
    /* Fix mobile viewport for landing page */
    .landing-page {
        min-height: 100vh;
        min-height: 100dvh;
        overflow-x: hidden;
    }
    
    .hero-section {
        flex-direction: column;
        text-align: center;
        gap: var(--space-xl);
        padding: var(--space-xl) var(--space-md);
        justify-content: center;
        min-height: 100vh;
        min-height: 100dvh;
    }
    
    .hero-content {
        max-width: 100%;
        padding-right: 0;
        text-align: center;
    }
    
    .hero-visual {
        min-height: 300px;
        width: 100%;
    }
    
    .chat-preview {
        max-width: 350px;
    }
    
    .chat-messages-preview {
        min-height: 200px;
    }
    
    /* Join Room Mobile Styles */
    .join-room {
        max-width: 100%;
        padding: var(--space-lg);
        margin: 0 auto;
    }
    
    .input-group {
        flex-direction: column;
        align-items: stretch;
        min-height: auto;
    }
    
    .url-prefix {
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        justify-content: center;
        padding: var(--space-sm) var(--space-md);
        font-size: var(--text-xs);
    }
    
    #roomInput {
        padding: var(--space-md);
        text-align: center;
        font-size: 16px !important; /* Prevent zoom on iOS */
        -webkit-appearance: none;
        border-radius: 0;
    }
    
    #joinRoomBtn {
        min-width: 100%;
        padding: var(--space-lg);
        font-size: var(--text-lg);
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    }
    
    #joinRoomBtn:hover {
        transform: translateY(-2px);
    }
    
    /* Mobile responsive for steps and rooms */
    .steps-container {
        max-width: 100%;
        gap: var(--space-md);
    }
    
    .step {
        padding: var(--space-lg);
        flex-direction: column;
        text-align: center;
        gap: var(--space-md);
        align-items: center;
    }
    
    .step-number {
        align-self: center;
    }
    
    .step-content {
        text-align: center;
    }
    
    .room-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(6, 1fr);
        max-width: 100%;
        gap: var(--space-md);
    }
    
    .room-card {
        padding: var(--space-lg);
        gap: var(--space-md);
    }
}

/* Tablet - Adjust proportions */
@media (min-width: 769px) and (max-width: 1024px) {
    .hero-section {
        gap: var(--space-xl);
        padding: var(--space-xl) var(--space-lg);
    }
    
    .hero-content {
        padding-right: var(--space-xl);
    }
    
    .hero-visual {
        width: 45%;
    }
    
    .chat-preview {
        max-width: 450px;
    }
    
    .chat-messages-preview {
        min-height: 250px;
    }
    
    /* Join Room Tablet Styles */
    .join-room {
        max-width: 450px;
    }
    
    .url-prefix {
        font-size: var(--text-sm);
        padding: var(--space-sm) var(--space-md);
    }
    
    #roomInput {
        font-size: var(--text-base);
    }
    
    #joinRoomBtn {
        min-width: 100px;
        font-size: var(--text-base);
    }
    
    /* Tablet responsive for steps and rooms */
    .room-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: var(--space-lg);
    }
    
    .steps-container {
        max-width: 600px;
    }
}

/* Large Desktop - Better balance */
@media (min-width: 1200px) {
    .hero-section {
        gap: 4rem;
        padding: var(--space-2xl) 2rem;
        max-width: 1500px;
    }
    
    .hero-content {
        max-width: 650px;
        padding-right: 3rem;
    }
    
    .hero-visual {
        width: 45%;
    }
    
    .chat-preview {
        max-width: 550px;
    }
    
    .chat-messages-preview {
        min-height: 350px;
        padding: var(--space-xl);
    }
    
    .container {
        max-width: 1500px;
    }
}

/* Extra Large Desktop - Maximum width */
@media (min-width: 1440px) {
    .hero-section {
        gap: 5rem;
        padding: var(--space-2xl) 3rem;
        max-width: 1600px;
    }
    
    .hero-content {
        max-width: 700px;
        padding-right: 4rem;
    }
    
    .hero-visual {
        width: 42%;
    }
    
    .chat-preview {
        max-width: 600px;
    }
    
    .container {
        max-width: 1600px;
    }
}

/* ========================================
   ENHANCED ANIMATIONS
   ======================================== */

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

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

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

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

@keyframes pulseRing {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

@keyframes recordingPulse {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.1);
    }
}

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

/* Smooth scrollbar for modern chat */
.messages-scroll-container::-webkit-scrollbar {
    width: 8px;
}

.messages-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-scroll-container::-webkit-scrollbar-thumb {
    background: var(--surface-bg);
    border-radius: var(--radius-full);
    border: 2px solid var(--secondary-bg);
}

.messages-scroll-container::-webkit-scrollbar-thumb:hover {
    background: var(--elevated-bg);
}

/* ========================================
   EXISTING STYLES (KEPT INTACT)
   ======================================== */

/* Keep all existing styles from #chatContainer onwards but replace with modern equivalents above */

#chatContainer {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--primary-bg);
    position: relative;
}

#chatContainer.hidden {
    display: none;
}

/* Voice Message Styles */
.voice-message-container {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid rgba(88, 166, 255, 0.2);
    border-radius: var(--radius-lg);
    max-width: 300px;
    transition: all var(--transition-normal);
}

.voice-message-container:hover {
    background: rgba(88, 166, 255, 0.15);
    border-color: rgba(88, 166, 255, 0.3);
}

.voice-play-button {
    width: 40px;
    height: 40px;
    background: var(--brand-gradient);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.voice-play-button:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.play-icon {
    position: relative;
}

.play-triangle {
    width: 0;
    height: 0;
    border-left: 8px solid white;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    margin-left: 2px;
}

.voice-play-button.playing .play-triangle {
    display: none;
}

.voice-play-button.playing::after {
    content: '';
    width: 12px;
    height: 12px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-left: 4px solid white;
    border-right: 4px solid white;
    border-top: none;
    border-bottom: none;
    background: transparent;
}

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

.wave-bar {
    width: 3px;
    background: var(--brand-primary);
    border-radius: 2px;
    opacity: 0.7;
    transition: all var(--transition-normal);
}

.wave-bar:nth-child(1) { height: 8px; }
.wave-bar:nth-child(2) { height: 16px; }
.wave-bar:nth-child(3) { height: 12px; }
.wave-bar:nth-child(4) { height: 20px; }
.wave-bar:nth-child(5) { height: 10px; }
.wave-bar:nth-child(6) { height: 18px; }
.wave-bar:nth-child(7) { height: 14px; }
.wave-bar:nth-child(8) { height: 8px; }

.voice-waveform:hover .wave-bar {
    opacity: 1;
    background: var(--brand-secondary);
}

.voice-duration {
    font-size: var(--text-xs);
    color: var(--brand-primary);
    font-family: 'Courier New', monospace;
    font-weight: 600;
    flex-shrink: 0;
    min-width: 35px;
    text-align: right;
}

/* Message Images */
.message-image {
    max-width: min(300px, 80vw);
    max-height: 300px;
    width: auto;
    height: auto;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    object-fit: contain;
    display: block;
}

.message-image:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

/* Own message voice containers */
.message.own .voice-message-container {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.message.own .voice-message-container:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
}

.message.own .wave-bar {
    background: rgba(255, 255, 255, 0.8);
}

.message.own .voice-waveform:hover .wave-bar {
    background: white;
}

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

/* Message highlight effect for new messages */
.message.highlighted {
    animation: messageHighlight 1s ease-out;
}

@keyframes messageHighlight {
    0% {
        transform: translateY(10px);
        opacity: 0;
        box-shadow: 0 0 0 rgba(88, 166, 255, 0.3);
    }
    50% {
        transform: translateY(0);
        opacity: 1;
        box-shadow: 0 0 20px rgba(88, 166, 255, 0.3);
    }
    100% {
        transform: translateY(0);
        opacity: 1;
        box-shadow: 0 0 0 rgba(88, 166, 255, 0);
    }
}

/* Enhanced smooth scrolling for the chat container */
.messages-scroll-container {
    scroll-behavior: smooth;
}

/* ========================================
   DRAG AND DROP STYLING
   ======================================== */

/* Drag and drop visual feedback */
.drag-over {
    position: relative;
    background: linear-gradient(135deg, 
        rgba(88, 166, 255, 0.1) 0%, 
        rgba(121, 192, 255, 0.05) 100%) !important;
    border: 2px dashed var(--brand-primary) !important;
    border-radius: var(--radius-lg);
}

.drag-over::before {
    content: '📷 Drop images here to upload';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--secondary-bg);
    border: 2px solid var(--brand-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg) var(--space-xl);
    color: var(--brand-primary);
    font-size: var(--text-lg);
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: var(--z-tooltip);
    white-space: nowrap;
    animation: dropZonePulse 1s infinite alternate;
}

@keyframes dropZonePulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.05);
        opacity: 1;
    }
}

/* Drag overlay styling */
.drag-over::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(88, 166, 255, 0.05);
    border-radius: var(--radius-lg);
    z-index: var(--z-dropdown);
}

/* Enhanced drag feedback for better UX */
.drag-over {
    transition: all var(--transition-normal);
    transform: scale(1.01);
    box-shadow: 
        0 0 20px rgba(88, 166, 255, 0.3),
        var(--shadow-lg);
}

/* Mobile drag and drop adjustments */
@media (max-width: 768px) {
    .drag-over::before {
        font-size: var(--text-base);
        padding: var(--space-md) var(--space-lg);
        white-space: normal;
        text-align: center;
        max-width: 80%;
        line-height: 1.4;
    }
    
    .drag-over {
        transform: scale(1.005); /* Less dramatic scaling on mobile */
    }
}

/* ========================================
   SWIPE TO REPLY FUNCTIONALITY
   ======================================== */

/* Reply indicator removed as requested */

/* Always visible reply button beside messages */
.reply-button {
    position: absolute;
    right: -30px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    z-index: 3;
    opacity: 0.8;
    padding: 2px;
    font-size: 14px;
    color: white !important;
    font-weight: bold;
    line-height: 1;
}

.reply-button:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.2);
}

.reply-button:active {
    transform: translateY(-50%) scale(0.9);
}

/* Show reply button on message hover (desktop) or always (mobile) */
@media (min-width: 769px) {
    .reply-button {
        opacity: 0.7;
        pointer-events: auto;
    }
    
    .message:hover .reply-button {
        opacity: 0.9;
        pointer-events: auto;
    }
    
    .message:hover .reply-button:hover {
        opacity: 1;
    }
}

/* Mobile - always show reply button with slight transparency */
@media (max-width: 768px) {
    .reply-button {
        right: -25px;
        width: 18px;
        height: 18px;
        opacity: 0.8;
        pointer-events: auto;
        padding: 2px;
        font-size: 12px;
        color: white !important;
        font-weight: bold;
    }
    
    .reply-button:active {
        opacity: 1;
        transform: translateY(-50%) scale(0.8);
    }
}

/* Position reply button for own messages (right side) */
.message.own .reply-button {
    right: auto;
    left: -30px;
    color: white !important;
}

@media (max-width: 768px) {
    .message.own .reply-button {
        left: -25px;
        color: white !important;
    }
}

/* Reply indicator CSS removed */

/* Message swipe states */
.message.swiping {
    transform: translateX(-60px);
}

.message.reply-triggered {
    animation: replyPulse 0.3s ease-out;
}

@keyframes replyPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Reply context in input area */
.reply-context {
    background: var(--tertiary-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--space-md) var(--space-lg);
    margin: 0 var(--space-sm);
    position: relative;
    animation: slideInUp var(--transition-normal);
}

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

.reply-context-label {
    font-size: var(--text-xs);
    color: var(--brand-primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.reply-context-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.reply-context-message {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
}

.reply-context-avatar {
    width: 24px;
    height: 24px;
    background: var(--brand-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    flex-shrink: 0;
}

.reply-context-content {
    flex: 1;
    min-width: 0;
}

.reply-context-sender {
    font-size: var(--text-xs);
    color: var(--brand-primary);
    font-weight: 600;
    margin-bottom: 2px;
}

.reply-context-text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.3;
    max-height: 40px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.reply-context-image {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-style: italic;
}

/* Replied message display */
.message-reply {
    background: var(--surface-bg);
    border-left: 3px solid var(--brand-primary);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-sm);
    position: relative;
}

.message-reply-header {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-bottom: var(--space-xs);
}

.message-reply-sender {
    font-size: var(--text-xs);
    color: var(--brand-primary);
    font-weight: 600;
}

.message-reply-text {
    font-size: var(--text-sm);
    color: var(--text-muted);
    line-height: 1.3;
    max-height: 36px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.message-reply-image {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-style: italic;
}

/* Own message reply styling */
.message.own .message-reply {
    background: rgba(255, 255, 255, 0.15);
    border-left-color: rgba(255, 255, 255, 0.8);
}

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

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

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

/* Desktop hover effects for reply indicator removed */

/* Mobile reply adjustments */
@media (max-width: 768px) {
    .reply-context {
        margin: 0 var(--space-xs);
        padding: var(--space-sm) var(--space-md);
    }
    
    .reply-context-text {
        font-size: var(--text-xs);
    }
    
    .message.swiping {
        transform: translateX(-50px);
    }
    
    /* Reply indicator mobile styles removed */
}

/* Ensure voice recording modal animations work properly */
@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes pulseRing {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

@keyframes recordingPulse {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.1);
    }
}

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

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