* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Prevent scrolling issues on mobile */
html {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* iOS Safari specific fixes */
@supports (-webkit-appearance: none) {
    html {
        height: -webkit-fill-available;
    }
    
    body {
        height: -webkit-fill-available;
    }
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height on supported browsers */
    overflow: hidden;
    font-size: 14px;
}

/* Base responsive font sizing */
@media (max-width: 768px) {
    body {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 11px;
        /* Fix for mobile browsers with dynamic viewport */
        height: 100vh;
        height: -webkit-fill-available;
        min-height: -webkit-fill-available;
    }
    
    /* Ensure proper mobile layout */
    .container {
        height: 100vh;
        height: -webkit-fill-available;
        min-height: -webkit-fill-available;
    }
}

/* Full Screen Login Design */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 2000;
    overflow: hidden;
}

.login-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    height: 100%;
    max-width: 1200px;
    position: relative;
    z-index: 10;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: white;
    text-align: center;
}

.brand-logo {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.brand-logo svg {
    color: white;
    width: 40px;
    height: 40px;
}

.brand-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.brand-subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    max-width: 400px;
    line-height: 1.6;
}

.login-form-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.login-form-container {
    width: 100%;
    max-width: 400px;
}

.login-title {
    font-size: 2rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    text-align: center;
}

.login-subtitle {
    color: #64748b;
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1rem;
}

.login-form-container .auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.login-form-container .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.login-form-container .form-group label {
    font-weight: 500;
    color: #374151;
    font-size: 0.9rem;
}

.login-form-container .form-group input {
    padding: 0.875rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: white;
}

.login-form-container .form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-btn {
    padding: 0.875rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.login-btn:active {
    transform: translateY(0);
}

.login-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
}

.bg-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Ccircle cx='20' cy='20' r='4'/%3E%3Ccircle cx='40' cy='40' r='4'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat;
    opacity: 0.5;
}

.floating-shapes {
    position: absolute;
    width: 100%;
    height: 100%;
}

.shape {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    animation: float 6s ease-in-out infinite;
}

.shape-1 {
    width: 80px;
    height: 80px;
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.shape-2 {
    width: 120px;
    height: 120px;
    top: 60%;
    right: 15%;
    animation-delay: 2s;
}

.shape-3 {
    width: 60px;
    height: 60px;
    bottom: 20%;
    left: 20%;
    animation-delay: 4s;
}

.shape-4 {
    width: 100px;
    height: 100px;
    top: 10%;
    right: 30%;
    animation-delay: 1s;
}

.shape-5 {
    width: 40px;
    height: 40px;
    bottom: 30%;
    right: 10%;
    animation-delay: 3s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-20px) rotate(180deg);
    }
}

/* Responsive Design for Login Screen */
@media (max-width: 1024px) {
    .login-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .login-brand {
        padding: 2rem;
    }
    
    .brand-title {
        font-size: 2.5rem;
    }
    
    .login-form-wrapper {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .login-brand {
        padding: 1.5rem;
    }
    
    .brand-title {
        font-size: 2rem;
    }
    
    .brand-subtitle {
        font-size: 1rem;
    }
    
    .login-form-wrapper {
        padding: 1.5rem;
        background: rgba(255, 255, 255, 0.98);
    }
    
    .login-title {
        font-size: 1.5rem;
    }
    
    .brand-logo {
        width: 60px;
        height: 60px;
        margin-bottom: 1.5rem;
    }
    
    .brand-logo svg {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 480px) {
    .login-container {
        height: 100vh;
        height: 100dvh;
    }
    
    .login-brand {
        padding: 1rem;
        min-height: auto;
    }
    
    .brand-title {
        font-size: 1.75rem;
        margin-bottom: 0.5rem;
    }
    
    .brand-subtitle {
        font-size: 0.9rem;
        margin-bottom: 0;
    }
    
    .login-form-wrapper {
        padding: 1rem;
        background: white;
    }
    
    .login-form-container {
        max-width: none;
    }
    
    .login-title {
        font-size: 1.25rem;
    }
    
    .login-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }
    
    .brand-logo {
        width: 50px;
        height: 50px;
        margin-bottom: 1rem;
    }
    
    .brand-logo svg {
        width: 25px;
        height: 25px;
    }
    
    .floating-shapes {
        display: none;
    }
}

/* Error styling for full screen login */
.login-form-container .error {
    color: #ef4444;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 0.75rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    text-align: center;
}

/* Modal Styles */
.modal {
    display: flex;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 400px;
    text-align: center;
    max-height: 90vh;
    overflow-y: auto;
}

/* Modal responsive adjustments */
@media (max-width: 768px) {
    .modal-content {
        padding: 1.5rem;
        width: 95%;
        max-width: 350px;
        border-radius: 8px;
    }
}

@media (max-width: 480px) {
    .modal-content {
        padding: 1rem;
        width: 95%;
        max-width: none;
        margin: 10px;
        border-radius: 6px;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.close-btn:hover {
    color: #000;
}

/* Auth Forms */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group input,
.form-group textarea {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.auth-form button,
.create-room-btn,
.logout-btn {
    padding: 12px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.auth-form button:hover,
.create-room-btn:hover,
.logout-btn:hover {
    background: #5a6fd8;
}

.error {
    color: #e74c3c;
    margin-top: 1rem;
    font-size: 14px;
}

.hidden {
    display: none !important;
}

/* Chat App Styles */
.chat-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height */
    background: white;
    min-height: 0; /* Allow proper flex shrinking */
}

.chat-header {
    background: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    z-index: 100; /* Ensure header stays below mobile sidebar */
}

.chat-header h1 {
    font-size: 24px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Mobile hamburger menu */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.mobile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    .chat-header {
        padding: 1rem;
    }
    
    .chat-header h1 {
        font-size: 20px;
    }
    
    .mobile-menu-btn {
        display: block;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 0.75rem;
    }
    
    .chat-header h1 {
        font-size: 18px;
    }
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logout-btn {
    padding: 8px 16px;
    font-size: 14px;
}

.chat-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: #34495e;
    color: white;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 100;
}

/* Mobile sidebar toggle */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0; /* Explicitly set bottom to 0 for full height */
        height: 100vh;
        height: 100dvh; /* Use dynamic viewport height */
        height: -webkit-fill-available; /* Safari fallback */
        width: 280px;
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
        z-index: 1000; /* Ensure sidebar appears above everything */
        margin: 0; /* Remove any potential margins */
        border: 0; /* Remove any potential borders */
    }
    
    .sidebar.open {
        transform: translateX(0);
        /* Force full height when opened */
        height: 100vh !important;
        height: 100dvh !important;
        height: -webkit-fill-available !important;
        top: 0 !important;
        bottom: 0 !important;
    }
    
    .sidebar.open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 280px;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }
    
    .chat-container {
        flex-direction: column;
        height: 100%;
        min-height: 0; /* Allow proper flex shrinking */
    }
    
    .chat-main {
        height: 100%;
        min-height: 0; /* Ensure proper flex behavior on mobile */
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 90vw;
        max-width: 300px;
        padding: 0.75rem;
        height: 100vh;
        height: 100dvh; /* Use dynamic viewport height */
        height: -webkit-fill-available; /* Safari fallback */
        bottom: 0; /* Explicitly set bottom to 0 for full height */
        margin: 0; /* Remove any potential margins */
        border: 0; /* Remove any potential borders */
    }
    
    .sidebar.open {
        /* Additional override for very small screens */
        width: 90vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        height: -webkit-fill-available !important;
    }
}

/* Desktop/Web optimizations - Higher specificity */
@media screen and (min-width: 769px) {
    .sidebar {
        position: static !important; /* Reset mobile positioning */
        transform: none !important; /* Reset mobile transform */
        height: auto !important; /* Let it fill naturally */
        width: 300px !important; /* Fixed width for desktop */
        box-shadow: none !important; /* Remove mobile shadow */
        z-index: auto !important; /* Reset mobile z-index */
        margin: 0 !important; /* Reset margins */
        border: 0 !important; /* Reset borders */
        top: auto !important; /* Reset mobile top */
        left: auto !important; /* Reset mobile left */
        bottom: auto !important; /* Reset mobile bottom */
        display: flex !important; /* Ensure flex display */
        flex-direction: column !important; /* Column layout */
    }
    
    .sidebar.open {
        transform: none !important; /* Disable mobile open state */
    }
    
    .chat-container {
        height: 100% !important; /* Ensure full height usage */
        flex-direction: row !important; /* Horizontal layout for desktop */
        min-height: 0 !important; /* Allow proper flex shrinking */
        display: flex !important; /* Ensure flex display */
        overflow: hidden !important; /* Prevent overflow issues */
        position: relative !important; /* Maintain positioning context */
    }
    
    .chat-main {
        height: 100% !important; /* Ensure full height */
        min-height: 0 !important; /* Allow flex shrinking */
        flex: 1 !important; /* Take remaining space */
    }
    
    .messages-container {
        /* Enhanced scrolling for desktop */
        scrollbar-width: thin;
        scrollbar-color: #ccc #f1f1f1;
        padding: 1.5rem; /* More padding on desktop */
    }
    
    .messages-container::-webkit-scrollbar {
        width: 8px;
    }
    
    .messages-container::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }
    
    .messages-container::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 4px;
    }
    
    .messages-container::-webkit-scrollbar-thumb:hover {
        background: #999;
    }
    
    /* Desktop message styling */
    .message {
        max-width: 70%; /* Better width on desktop */
    }
    
    .chat-room-header {
        padding: 1.5rem 2rem; /* More padding on desktop */
    }
    
    .message-input-container {
        padding: 1.5rem; /* More padding on desktop */
    }
    
    /* Better button styling on desktop */
    .media-btn {
        width: 40px;
        height: 40px;
        padding: 10px;
    }
    
    .media-btn:hover {
        background: #e3f2fd;
        transform: scale(1.05);
    }
    
    /* Desktop sidebar styling */
    .nav-tab {
        padding: 12px 16px;
        font-size: 15px;
    }
    
    .create-room-btn,
    .room-item,
    .user-item,
    .conversation-item {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .create-room-btn:hover,
    .room-item:hover,
    .user-item:hover,
    .conversation-item:hover {
        transform: translateX(2px);
        transition: transform 0.2s ease;
    }
    
    /* Desktop input improvements */
    .message-input input {
        font-size: 15px;
        padding: 12px 16px;
    }
    
    .message-input button {
        padding: 12px 20px;
        font-size: 15px;
    }
    
    /* Desktop modal improvements */
    .modal-content {
        min-width: 500px;
        max-width: 90vw;
    }
    
    /* Better desktop scrollbars for sidebar */
    .sidebar::-webkit-scrollbar {
        width: 6px;
    }
    
    .sidebar::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .sidebar::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 3px;
    }
    
    .sidebar::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.5);
    }
    
    /* Ensure mobile elements are hidden on desktop */
    .mobile-menu-btn {
        display: none !important;
    }
    
    /* Force proper chat app layout on desktop */
    .chat-app {
        height: 100vh !important;
        height: 100dvh !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    /* Ensure header stays at top */
    .chat-header {
        flex-shrink: 0 !important;
        position: relative !important;
    }
}

/* Additional desktop-only fixes with highest specificity */
@media screen and (min-width: 769px) {
    html .chat-app .chat-container {
        flex-direction: row !important;
        height: 100% !important;
    }
    
    html .chat-app .sidebar {
        position: static !important;
        transform: none !important;
        width: 300px !important;
        height: auto !important;
    }
    
    html .chat-app .chat-main {
        flex: 1 !important;
        height: 100% !important;
        min-height: 0 !important;
    }
}

.rooms-section,
.users-section {
    margin-bottom: 2rem;
}

.rooms-section h3,
.users-section h3 {
    margin-bottom: 1rem;
    font-size: 18px;
    color: #ecf0f1;
}

.rooms-list,
.users-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.room-item {
    padding: 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.room-item:hover {
    background: rgba(255,255,255,0.2);
}

.room-item.active {
    background: #667eea;
}

.user-item {
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-status {
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
}

.create-room-btn {
    margin-top: 1rem;
    width: 100%;
}

/* WhatsApp-like Chat Interface */
.chat-header-section {
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1rem;
}

.chat-header-section h2 {
    color: #ecf0f1;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.search-bar {
    position: relative;
}

.search-bar input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    color: white;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-bar input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-bar input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #2c3e50;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    margin-top: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.search-dropdown.hidden {
    display: none;
}

.search-user-result {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.search-user-result:hover {
    background: rgba(255, 255, 255, 0.1);
}

.search-user-result:last-child {
    border-bottom: none;
}

.search-user-avatar {
    width: 32px;
    height: 32px;
    background: #667eea;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.search-user-info {
    flex: 1;
    min-width: 0;
}

.search-user-name {
    font-weight: 500;
    color: white;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-user-status {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.all-contacts-section {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.all-contacts-section h3 {
    color: #ecf0f1;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-weight: 600;
}

.all-contacts-section h3::before {
    content: '👥';
    font-size: 1rem;
}

.online-count {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.online-count::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2ecc71;
}

.all-contacts-list {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    flex: 1;
    overflow-y: auto;
    padding-right: 0.25rem;
}

/* Custom scrollbar for contacts list */
.all-contacts-list::-webkit-scrollbar {
    width: 4px;
}

.all-contacts-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

.all-contacts-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.all-contacts-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.contact-item {
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    border: 1px solid transparent;
    position: relative;
    margin-bottom: 0.1rem;
}

.contact-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateX(3px);
}

.contact-item.online::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #2ecc71;
    border-radius: 0 2px 2px 0;
}

.contact-item.offline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #95a5a6;
    border-radius: 0 2px 2px 0;
}

.contact-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.contact-avatar.online::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #2ecc71;
    border: 2px solid #34495e;
    border-radius: 50%;
}

.contact-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.contact-name {
    font-weight: 600;
    color: white;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.contact-item.online .contact-name::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2ecc71;
    flex-shrink: 0;
    animation: pulse-online 2s infinite;
}

@keyframes pulse-online {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1);
    }
    50% { 
        opacity: 0.6; 
        transform: scale(1.2);
    }
}

.contact-status {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    position: relative;
}

.contact-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #95a5a6;
    flex-shrink: 0;
}

.contact-status.online {
    color: #2ecc71;
    font-weight: 500;
}

.contact-status.online::before {
    background: #2ecc71;
    box-shadow: 0 0 4px rgba(46, 204, 113, 0.4);
}

.contact-status.offline {
    color: rgba(255, 255, 255, 0.5);
}

.contact-status.offline::before {
    background: #95a5a6;
}

.contact-quick-action {
    opacity: 0;
    transition: opacity 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
}

.contact-item:hover .contact-quick-action {
    opacity: 1;
}

.contact-quick-action:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Empty state for contacts */
.contacts-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: rgba(255, 255, 255, 0.5);
}

.contacts-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.contacts-empty-text {
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Improved search styling */
.search-bar input {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 25px;
    color: white;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-bar input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-bar input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* All users section styling updates */
.all-users-section {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
}

.all-users-section h3 {
    color: #ecf0f1;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.all-users-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 200px;
    overflow-y: auto;
}

.user-list-item {
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid transparent;
}

.user-list-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateX(2px);
}

.user-list-item.online {
    border-left: 3px solid #2ecc71;
}

.user-list-item.offline {
    border-left: 3px solid #95a5a6;
    opacity: 0.8;
}

.user-list-avatar {
    width: 28px;
    height: 28px;
    background: #667eea;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.user-list-info {
    flex: 1;
    min-width: 0;
}

.user-list-name {
    font-weight: 500;
    color: white;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-list-status {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Conversation items matching contact card design exactly */
.conversation-item {
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    border: 1px solid transparent;
    position: relative;
    margin-bottom: 0.1rem;
}

.conversation-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateX(3px);
}

.conversation-item.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.conversation-item.online::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #2ecc71;
    border-radius: 0 2px 2px 0;
}

.conversation-item.offline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #95a5a6;
    border-radius: 0 2px 2px 0;
}

.conversation-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: white;
    border-radius: 0 2px 2px 0;
}

.conversation-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    position: relative;
}

.conversation-avatar.online::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #2ecc71;
    border: 2px solid #34495e;
    border-radius: 50%;
}

.conversation-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversation-name {
    font-weight: 600;
    color: white;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-time {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    flex-shrink: 0;
}

.conversation-status {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.conversation-status.online {
    color: #2ecc71;
}

.conversation-status.offline {
    color: rgba(255, 255, 255, 0.5);
}

.conversation-item.active .conversation-name {
    color: white;
}

.conversation-item.active .conversation-status {
    color: rgba(255, 255, 255, 0.9);
}

.conversation-item.active .conversation-time {
    color: rgba(255, 255, 255, 0.8);
}

.conversation-quick-action {
    opacity: 0;
    transition: opacity 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
}

.conversation-item:hover .conversation-quick-action {
    opacity: 1;
}

.conversation-quick-action:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.conversation-item.active .conversation-quick-action {
    background: rgba(255, 255, 255, 0.2);
}

/* Unread message indicator */
.conversation-unread {
    background: #2ecc71;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    font-size: 0.7rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.3rem;
}

/* Last message status icons */
.message-status-icon {
    width: 12px;
    height: 12px;
    opacity: 0.7;
}

/* Mobile responsive for WhatsApp-like interface */
@media (max-width: 768px) {
    .chat-header-section {
        padding: 0.75rem 0;
    }
    
    .chat-header-section h2 {
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }
    
    .search-bar input {
        padding: 0.7rem 0.9rem;
        font-size: 0.85rem;
    }
    
    .conversation-item {
        padding: 0.8rem;
        gap: 0.6rem;
    }
    
    .conversation-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    .contact-item {
        padding: 0.7rem;
        gap: 0.7rem;
    }
    
    .contact-avatar {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .contact-quick-action {
        width: 28px;
        height: 28px;
    }
    
    .contact-quick-action svg {
        width: 14px;
        height: 14px;
    }
    
    .all-contacts-section h3,
    .conversations-section h3 {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .chat-header-section {
        padding: 0.5rem 0;
    }
    
    .chat-header-section h2 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .search-bar input {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .conversation-item {
        padding: 0.7rem;
        gap: 0.5rem;
        margin-bottom: 0.3rem;
    }
    
    .conversation-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
    
    .conversation-name {
        font-size: 0.9rem;
    }
    
    .conversation-preview {
        font-size: 0.8rem;
    }
    
    .conversation-time {
        font-size: 0.7rem;
    }
    
    .contact-item {
        padding: 0.6rem;
        gap: 0.6rem;
        margin-bottom: 0.05rem;
    }
    
    .contact-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    .contact-avatar.online::after {
        width: 10px;
        height: 10px;
        border-width: 1.5px;
    }
    
    .contact-name {
        font-size: 0.9rem;
    }
    
    .contact-status {
        font-size: 0.75rem;
    }
    
    .contact-quick-action {
        width: 26px;
        height: 26px;
        opacity: 1; /* Always visible on mobile */
    }
    
    .contact-quick-action svg {
        width: 12px;
        height: 12px;
    }
    
    .all-contacts-list {
        gap: 0.05rem;
    }
    
    .all-contacts-section h3,
    .conversations-section h3 {
        font-size: 0.9rem;
        margin-bottom: 0.6rem;
    }
    
    .conversations-section {
        margin-bottom: 1rem;
    }
    
    /* Make contacts more touch-friendly */
    .contact-item:hover {
        transform: none; /* Disable hover transform on mobile */
    }
    
    .contact-item:active {
        background: rgba(255, 255, 255, 0.12);
        transform: scale(0.98);
    }
}

/* Navigation Tabs - Hidden since rooms functionality is commented out */
.nav-tabs {
    display: none !important;
}

.nav-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    transition: all 0.3s;
}

.nav-tab.active {
    color: white;
    border-bottom-color: #667eea;
}

.nav-tab:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Direct Messages */
.direct-section {
    margin-bottom: 2rem;
}

.direct-section h3 {
    margin-bottom: 1rem;
    font-size: 18px;
    color: #ecf0f1;
}

.conversations-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.conversation-item {
    padding: 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.conversation-item:hover {
    background: rgba(255,255,255,0.2);
}

.conversation-item.active {
    background: #667eea;
}

.conversation-name {
    font-weight: 500;
    font-size: 14px;
}

.conversation-preview {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-time {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    align-self: flex-end;
}

/* Direct Users Lists */
.online-users-section,
.offline-users-section {
    margin-bottom: 1.5rem;
}

.online-users-section h3,
.offline-users-section h3 {
    margin-bottom: 0.75rem;
    font-size: 16px;
    color: #ecf0f1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.online-users-section h3::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    display: inline-block;
}

.offline-users-section h3::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #95a5a6;
    border-radius: 50%;
    display: inline-block;
}

.direct-users-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 150px;
    overflow-y: auto;
}

.direct-user-item {
    padding: 8px 10px;
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 13px;
}

.direct-user-item:hover {
    background: rgba(255,255,255,0.15);
    transform: translateX(2px);
}

.direct-user-item.online {
    border-left: 3px solid #2ecc71;
}

.direct-user-item.offline {
    border-left: 3px solid #95a5a6;
    opacity: 0.8;
}

.direct-user-avatar {
    width: 24px;
    height: 24px;
    background: #667eea;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 11px;
    flex-shrink: 0;
}

.direct-user-info {
    flex: 1;
    overflow: hidden;
}

.direct-user-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.direct-user-status {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    margin-top: 1px;
}

/* User Search */
.users-search {
    margin-bottom: 1rem;
}

.users-search input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    margin-bottom: 0.5rem;
}

.search-results {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
}

.search-user-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.3s;
}

.search-user-item:hover {
    background: #f5f5f5;
}

.search-user-item:last-child {
    border-bottom: none;
}

.search-user-avatar {
    width: 32px;
    height: 32px;
    background: #667eea;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    height: 0; /* Force flex child to constrain height */
    min-height: 0; /* Allow shrinking */
}

.chat-room-header {
    background: white;
    padding: 1rem 2rem;
    border-bottom: 1px solid #e9ecef;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex-shrink: 0; /* Prevent header from shrinking */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-room-header h2 {
    color: #2c3e50;
    font-size: 20px;
    margin: 0;
}

.refresh-chat-btn {
    background: rgba(45, 62, 80, 0.1);
    border: 1px solid rgba(45, 62, 80, 0.3);
    color: #2c3e50;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    backdrop-filter: blur(10px);
    z-index: 1000;
    position: relative;
}

.refresh-chat-btn:hover {
    background: rgba(45, 62, 80, 0.2);
    border-color: rgba(45, 62, 80, 0.5);
    transform: rotate(180deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.refresh-chat-btn:active {
    transform: rotate(180deg) scale(0.95);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    height: 0; /* Force proper flex sizing */
    min-height: 0; /* Allow shrinking */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    overscroll-behavior: contain; /* Prevent scroll chaining */
    scroll-behavior: smooth; /* Smooth scrolling */
    width: 100%;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.message {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    word-wrap: break-word;
    /* Remove align-self/background here, handled in .own and not(.own) */
}

/* Message responsive adjustments */
@media (max-width: 768px) {
    .messages-container {
        padding: 0.75rem;
        /* Improve mobile scrolling performance */
        transform: translateZ(0);
        will-change: scroll-position;
    }
    
    .messages-list {
        gap: 0.75rem;
    }
    
    .message {
        max-width: 85%;
    }
    
    .chat-room-header {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 480px) {
    .messages-container {
        padding: 0.5rem;
        /* Enhanced mobile scrolling */
        overscroll-behavior-y: contain;
        scroll-behavior: smooth;
        width: 100vw;
        max-width: 100vw;
    }
    .messages-list {
        gap: 0.5rem;
        width: 100vw;
        max-width: 100vw;
    }
    .message {
        width: 100vw;
        max-width: 100vw;
    }
}

.message.own {
    align-self: flex-end;
}

/* Right side (login user) message bubble */
.message.own .message-content {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 6px;
    border-bottom-left-radius: 18px;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    margin-left: auto;
    margin-right: 0;
    align-self: flex-end;
    border: none;
}

/* Left side (sender) message bubble */
.message:not(.own) {
    align-self: flex-start;
}
.message:not(.own) .message-content {
    background: #fff;
    color: #222;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 18px;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    margin-left: 0;
    margin-right: auto;
    border: 1px solid #e3e6f0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    padding: 0.25rem 0;
}

.message-username {
    font-weight: 600;
    color: white;
}

.message-time {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
}

.sender-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 12px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
}

.message.own .sender-avatar {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
}

.message-content {
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    font-size: 14px;
    line-height: 1.4;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 0.25rem;
}

/* Message Read Status */
.read-indicator {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.25rem;
    padding: 0 0.5rem;
}

.read-status, .sent-status {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 11px;
    color: #4fc3f7;
}

.sent-status {
    color: #90a4ae;
}

.read-status svg, .sent-status svg {
    width: 12px;
    height: 12px;
}

/* Unread Message Badges */
.unread-badge {
    background: #f44336;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 0.5rem;
    min-width: 18px;
    text-align: center;
    display: none;
}

.room-item, .conversation-item {
    position: relative;
}

.room-item .unread-badge, .conversation-item .unread-badge {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

.typing-indicator {
    padding: 0.5rem 1rem;
    font-style: italic;
    color: #666;
    font-size: 14px;
    min-height: 1.5rem;
    flex-shrink: 0; /* Prevent shrinking that could affect layout */
}

.message-input-container {
    padding: 0.75rem 1rem;
    background: #f0f0f0;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0; /* Prevent input area from shrinking */
}

/* WhatsApp-style input wrapper */
.whatsapp-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.media-options-left {
    display: flex;
    align-items: center;
}

.media-btn {
    padding: 10px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: #54656f;
}

.media-btn:hover {
    background: rgba(84, 101, 111, 0.1);
}

/* Main input area styling */
.message-input-area {
    flex: 1;
    background: white;
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-input-area:focus-within {
    border-color: #00a884;
    box-shadow: 0 2px 8px rgba(0, 168, 132, 0.15);
}

.message-input-area input {
    flex: 1;
    border: none;
    outline: none;
    padding: 8px 0;
    font-size: 15px;
    color: #3b4a54;
    background: transparent;
    min-height: 20px;
    max-height: 100px;
    line-height: 20px;
}

.message-input-area input::placeholder {
    color: #8696a0;
}

/* Attachment options inside input */
.attachment-options {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.attachment-btn {
    background: transparent;
    border: none;
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    color: #54656f;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.attachment-btn:hover:not(:disabled) {
    background: rgba(84, 101, 111, 0.1);
}

.attachment-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* WhatsApp-style send button */
.whatsapp-send-btn {
    background: #00a884;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 168, 132, 0.3);
}

.whatsapp-send-btn:hover:not(:disabled) {
    background: #017c69;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 168, 132, 0.4);
}

.whatsapp-send-btn:active {
    transform: scale(0.95);
}

.whatsapp-send-btn:disabled {
    background: #bdbdbd;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.whatsapp-send-btn svg {
    margin-left: 2px; /* Slight offset to center the send arrow */
}

/* Input container responsive adjustments */
@media (max-width: 768px) {
    .message-input-container {
        padding: 0.5rem;
    }
    
    .whatsapp-input-wrapper {
        gap: 0.5rem;
    }
    
    .message-input-area {
        padding: 6px 12px;
    }
    
    .whatsapp-send-btn {
        width: 42px;
        height: 42px;
    }
}
    
    .media-btn {
        width: 32px;
        height: 32px;
        padding: 6px;
    }
    
    .media-btn svg {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 480px) {
    .message-input-container {
        padding: 0.5rem 0.75rem;
    }
    
    .whatsapp-input-wrapper {
        gap: 0.4rem;
    }
    
    .media-btn {
        width: 36px;
        height: 36px;
        padding: 8px;
    }
    
    .message-input-area {
        padding: 6px 10px;
    }
    
    .attachment-btn {
        width: 28px;
        height: 28px;
    }
    
    .whatsapp-send-btn {
        width: 40px;
        height: 40px;
    }
}

/* Media button disabled state */
.media-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    color: #bdbdbd;
}

.media-btn:disabled:hover {
    background: transparent;
    transform: none;
}

.media-btn svg {
    width: 20px;
    height: 20px;
}

/* Old message-input styles replaced with WhatsApp-style components */

/* Message input responsive adjustments */
@media (max-width: 768px) {
    .message-input {
        gap: 0.75rem;
    }
    
    .message-input input {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .message-input button {
        padding: 10px 20px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .message-input {
        gap: 0.5rem;
    }
    
    .message-input input {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .message-input button {
        padding: 8px 16px;
        font-size: 14px;
    }
}

/* Emoji Picker */
.emoji-picker {
    max-width: 400px;
    max-height: 500px;
    overflow-y: auto;
}

.emoji-categories {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.emoji-category h4 {
    margin: 0 0 0.5rem 0;
    font-size: 14px;
    color: #666;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.25rem;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.25rem;
}

.emoji-item {
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 20px;
    text-align: center;
    transition: background 0.2s;
    user-select: none;
}

.emoji-item:hover {
    background: #f0f0f0;
}

/* Media Preview */
.media-preview {
    max-width: 500px;
    max-height: 600px;
}

.media-preview-content {
    padding: 1rem 0;
    text-align: center;
    max-height: 400px;
    overflow-y: auto;
}

.media-preview-item {
    margin-bottom: 1rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e9ecef;
}

.media-preview-item img {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

.media-preview-item video {
    max-width: 100%;
    max-height: 300px;
}

.file-preview {
    padding: 1rem;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: #667eea;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.file-size {
    font-size: 12px;
    color: #666;
}

.media-preview-actions {
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.media-preview-actions input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.media-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.media-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.media-actions button:first-child {
    background: #6c757d;
    color: white;
}

.media-actions button:last-child {
    background: #667eea;
    color: white;
}

.media-actions button:hover {
    opacity: 0.9;
}

/* Media Messages */
.message-media {
    margin-top: 0.5rem;
    border-radius: 8px;
    overflow: hidden;
    max-width: 300px;
}

.message-media img {
    width: 100%;
    height: auto;
    display: block;
}

.message-media video {
    width: 100%;
    height: auto;
    display: block;
}

.message-file {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 300px;
}

.message-file .file-icon {
    width: 32px;
    height: 32px;
    font-size: 12px;
}

.message-caption {
    margin-top: 0.5rem;
    font-style: italic;
    color: #666;
    font-size: 13px;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.form-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.form-actions button[type="button"] {
    background: #95a5a6;
    color: white;
}

.form-actions button[type="submit"] {
    background: #667eea;
    color: white;
}

/* System Messages */
.system-message {
    text-align: center;
    color: #666;
    font-style: italic;
    font-size: 12px;
    margin: 0.5rem 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 250px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .modal-content {
        margin: 1rem;
        width: calc(100% - 2rem);
    }
}

@media (max-width: 480px) {
    .chat-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: 200px;
    }
    
    .chat-header {
        padding: 1rem;
    }
    
    .chat-header h1 {
        font-size: 20px;
    }
}

/* Media Message Styles */
.media-message {
    margin: 0.75rem 0;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Media Image Container */
.media-image-container {
    position: relative;
    display: inline-block;
    border-radius: 12px;
    overflow: hidden;
}

.media-image {
    max-width: 350px;
    max-height: 350px;
    min-width: 200px;
    min-height: 150px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: block;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.media-image:hover {
    opacity: 0.9;
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.media-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.media-image-container:hover .media-overlay {
    opacity: 1;
}

.image-loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.media-download-btn {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    padding: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

.media-download-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

.media-download-btn svg {
    width: 16px;
    height: 16px;
}

/* Media Video Container */
.media-video-container {
    position: relative;
    display: inline-block;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.media-video {
    max-width: 450px;
    max-height: 350px;
    min-width: 300px;
    border-radius: 12px;
    display: block;
    background: rgba(0, 0, 0, 0.1);
}

.video-download {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.media-video-container:hover .video-download {
    opacity: 1;
}

/* Media Audio Container */
.media-audio-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.media-audio {
    width: 300px;
}

.audio-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.audio-download {
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
    color: #4caf50;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    transition: all 0.2s;
}

.audio-download:hover {
    background: rgba(76, 175, 80, 0.2);
    border-color: rgba(76, 175, 80, 0.5);
}

.audio-download svg {
    width: 12px;
    height: 12px;
}

/* Unavailable Media Placeholder */
.media-message.unavailable {
    opacity: 0.7;
}

.media-placeholder {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 15px;
    max-width: 300px;
}

.placeholder-icon {
    color: rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
}

.placeholder-text {
    flex: 1;
}

.placeholder-text .file-name {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 2px;
}

.placeholder-text .error-text {
    font-size: 12px;
    color: rgba(255, 87, 34, 0.8);
    font-style: italic;
}

.file-attachment {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px 15px;
    margin: 5px 0;
    transition: background-color 0.2s;
}

.file-attachment:hover {
    background: rgba(255, 255, 255, 0.2);
}

.file-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    gap: 10px;
}

.file-icon {
    font-size: 24px;
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-name {
    font-weight: 500;
    font-size: 14px;
    color: #333;
    word-break: break-word;
}

.file-download-hint {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #666;
    opacity: 0.8;
}

.file-download-hint svg {
    width: 10px;
    height: 10px;
}

.file-attachment-missing {
    display: inline-block;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    border-radius: 8px;
    padding: 10px 15px;
    margin: 5px 0;
    opacity: 0.7;
}

.file-attachment-missing .file-name {
    color: #666;
    font-style: italic;
}

.media-caption {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0 0 12px 12px;
    line-height: 1.4;
}

/* Dark theme adjustments for media */
.message.own .file-name {
    color: #fff;
}

.message.own .media-caption {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.4);
}

/* Responsive media */
@media (max-width: 768px) {
    .media-image {
        max-width: min(250px, 90vw);
        max-height: 200px;
    }
    
    .media-video {
        max-width: min(300px, 90vw);
        max-height: 180px;
    }
    
    .media-audio {
        width: min(250px, 90vw);
    }
    
    .media-download-btn {
        padding: 6px;
    }
    
    .media-download-btn svg {
        width: 14px;
        height: 14px;
    }
}

@media (max-width: 480px) {
    .media-image {
        max-width: min(200px, 85vw);
        max-height: 150px;
    }
    
    .media-video {
        max-width: min(250px, 85vw);
        max-height: 140px;
    }
    
    .media-audio {
        width: min(200px, 85vw);
    }
    
    .media-download-btn {
        padding: 4px;
        font-size: 10px;
    }
    
    .media-download-btn svg {
        width: 12px;
        height: 12px;
    }
    
    .audio-download {
        padding: 4px 8px;
        font-size: 10px;
    }
    
    .file-attachment {
        padding: 8px 12px;
    }
    
    .media-overlay {
        top: 4px;
        right: 4px;
    }
}

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 9999;
    transform: translateX(400px);
    transition: transform 0.3s ease-in-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 300px;
    word-wrap: break-word;
}

/* Notification responsive adjustments */
@media (max-width: 768px) {
    .notification {
        top: 15px;
        right: 15px;
        left: 15px;
        max-width: none;
        padding: 10px 16px;
        font-size: 14px;
        transform: translateY(-100px);
    }
    
    .notification.show {
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        padding: 8px 12px;
        font-size: 12px;
        border-radius: 6px;
    }
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    background: linear-gradient(135deg, #4CAF50, #45a049);
}

.notification-error {
    background: linear-gradient(135deg, #f44336, #da190b);
}

.notification-info {
    background: linear-gradient(135deg, #2196F3, #1976D2);
}

/* Image Context Menu */
.image-context-menu {
    position: fixed;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    min-width: 160px;
    overflow: hidden;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
    color: #333;
}

.context-menu-item:hover {
    background-color: #f5f5f5;
}

.context-menu-item svg {
    width: 16px;
    height: 16px;
    color: #666;
}

.context-menu-item:hover svg {
    color: #333;
}

/* Additional mobile improvements */
@media (max-width: 768px) {
    /* Ensure main content takes full width on mobile */
    .main-content {
        width: 100%;
        min-height: 0;
    }
    
    /* Better touch targets */
    .nav-tab, .room-item, .create-room-btn, .start-chat-btn {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 12px;
    }
    
    /* Improve context menu for touch */
    .image-context-menu {
        min-width: 180px;
    }
    
    .context-menu-item {
        padding: 16px;
        font-size: 16px;
    }
    
    /* Better emoji picker for mobile */
    .emoji-container {
        max-height: 300px;
    }
    
    .emoji-item {
        padding: 12px;
        font-size: 20px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Prevent horizontal scroll on mobile */
@media (max-width: 480px) {
    * {
        max-width: 100%;
    }
    
    /* Ensure proper text wrapping */
    .message-content, .media-caption, .file-name {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    /* Better spacing for small screens */
    .rooms-section, .direct-section {
        padding: 0.5rem 0;
    }
    
    .nav-tabs {
        gap: 0;
    }
    
    .nav-tab {
        flex: 1;
        text-align: center;
        border-radius: 0;
        min-height: 48px;
    }
}

/* Landscape mobile adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .messages-container {
        padding: 0.5rem;
    }
    
    .message-input-container {
        padding: 0.5rem;
    }
    
    .media-image {
        max-height: 120px;
    }
    
    .media-video {
        max-height: 120px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .media-download-btn, .media-btn {
        border-width: 0.5px;
    }
}

/* Date Separator Styles */
.date-separator {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.date-separator-line {
    height: 1px;
    background: #e0e0e0;
    position: relative;
}

.date-separator-text {
    background: #f5f5f5;
    color: #666;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid #e0e0e0;
}

/* Collapsible Date Groups */
.date-group {
    margin-bottom: 20px;
}

.date-group.collapsed .messages-for-date {
    display: none;
}

.date-group.collapsed .date-separator-text {
    background: #e3f2fd;
    color: #1976d2;
    cursor: pointer;
    transition: all 0.2s ease;
}

.date-group.collapsed .date-separator-text:hover {
    background: #bbdefb;
}

.date-group.current-date .date-separator-text {
    background: #e8f5e8;
    color: #2e7d32;
    font-weight: 600;
}

.date-separator-text.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.date-separator-text.clickable:hover {
    background: #eeeeee;
    transform: translate(-50%, -50%) scale(1.05);
}

.messages-for-date {
    transition: all 0.3s ease;
}