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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    min-height: 100vh;
    color: #333;
    padding: 20px;
}

.chat-container {
    max-width: 1400px;
    margin: 0 auto;
    height: calc(100vh - 40px);
    position: relative;
}

/* Modal de entrada */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: linear-gradient(145deg, #ffffff, #f8fafc);
    padding: 2.5rem;
    border-radius: 25px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    text-align: center;
    min-width: 350px;
    backdrop-filter: blur(10px);
}

.modal-content h2 {
    color: #1e3a8a;
    margin-bottom: 1.5rem;
    font-size: 2rem;
    font-weight: 600;
}

.modal-content input {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e1e8ed;
    border-radius: 15px;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
}

.modal-content input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
    background: white;
}

.modal-content button {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #3b82f6, #1e40af);
    color: white;
    border: none;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-content button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4);
}

/* Interfaz principal flotante */
.chat-interface {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(145deg, #ffffff, #f1f5f9);
    border-radius: 25px;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-header {
    background: linear-gradient(135deg, #1e40af, #3b82f6, #60a5fa);
    color: white;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.chat-header h1 {
    font-size: 1.6rem;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.current-user-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.user-avatar {
    font-size: 1.2rem;
}

.username {
    font-weight: 600;
    font-size: 1.1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sound-btn, .clear-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

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

#logoutBtn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

#logoutBtn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.chat-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar de usuarios simplificada */
.users-sidebar {
    width: 250px;
    background: linear-gradient(180deg, #f8fafc, #e2e8f0);
    border-right: 1px solid #e1e8ed;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #e1e8ed;
    background: white;
}

.sidebar-header h3 {
    color: #1e40af;
    font-size: 1rem;
    font-weight: 600;
}

.users-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 12px;
    margin-bottom: 0.25rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.user-item:hover {
    background: rgba(59, 130, 246, 0.1);
}

.user-item.current-user {
    background: linear-gradient(135deg, #3b82f6, #1e40af);
    color: white;
}

.user-status {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    flex-shrink: 0;
}

.user-name {
    font-weight: 500;
    flex: 1;
}

/* Área de mensajes */
.messages-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
}

/* Mensajes */
.message {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 15px;
    max-width: 70%;
    word-wrap: break-word;
    position: relative;
    animation: fadeIn 0.3s ease;
}

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

.message.own {
    background: linear-gradient(135deg, #3b82f6, #1e40af);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.message.other {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    color: #1f2937;
    margin-right: auto;
    border-bottom-left-radius: 5px;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    opacity: 0.8;
}

.message-content {
    font-size: 1rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.reply-to {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    border-left: 3px solid rgba(255, 255, 255, 0.5);
}

.message.other .reply-to {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: #3b82f6;
}

.message-reactions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.reaction {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.message.other .reaction {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}

.reaction:hover {
    transform: scale(1.1);
}

.reaction.own-reaction {
    background: rgba(255, 255, 255, 0.4);
    font-weight: bold;
}

.message.other .reaction.own-reaction {
    background: rgba(59, 130, 246, 0.2);
}

.message-actions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.message:hover .message-actions {
    opacity: 1;
}

.action-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.message.other .action-btn {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.action-btn:hover {
    transform: scale(1.1);
}

/* Área de respuesta mejorada */
.reply-area {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-top: 1px solid #bfdbfe;
    padding: 1rem;
    margin: 0 1rem;
    border-radius: 12px 12px 0 0;
}

.reply-preview {
    background: white;
    border-radius: 10px;
    padding: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    color: #3b82f6;
    font-weight: 600;
    font-size: 0.9rem;
}

.cancel-reply {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 2px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.cancel-reply:hover {
    background: #f3f4f6;
    color: #ef4444;
}

.reply-content strong {
    color: #1e40af;
    font-size: 0.9rem;
}

.reply-content p {
    color: #6b7280;
    font-size: 0.85rem;
    margin-top: 0.25rem;
    font-style: italic;
}

/* Formulario de mensaje */
.message-form {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-top: 1px solid #e2e8f0;
}

.message-form input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.message-form input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.message-form button {
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

#emojiBtn {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    font-size: 1.1rem;
}

#emojiBtn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(251, 191, 36, 0.4);
}

.message-form button[type="submit"] {
    background: linear-gradient(135deg, #3b82f6, #1e40af);
    color: white;
}

.message-form button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

/* Panel de emojis mejorado */
.emoji-panel {
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 300px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    border: 1px solid #e2e8f0;
    z-index: 1000;
    overflow: hidden;
}

.emoji-categories {
    display: flex;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-bottom: 1px solid #e2e8f0;
}

.emoji-cat {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.emoji-cat.active {
    background: linear-gradient(135deg, #3b82f6, #1e40af);
    color: white;
}

.emoji-cat:hover:not(.active) {
    background: rgba(59, 130, 246, 0.1);
}

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

.emoji {
    padding: 8px;
    text-align: center;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.emoji:hover {
    background: #f3f4f6;
    transform: scale(1.2);
}

/* Panel de reacciones flotante */
.reaction-panel {
    position: absolute;
    background: white;
    border-radius: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 1px solid #e2e8f0;
    z-index: 1001;
    padding: 8px;
    backdrop-filter: blur(10px);
}

.reaction-emojis {
    display: flex;
    gap: 4px;
}

.reaction-emoji {
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 15px;
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

.reaction-emoji:hover {
    background: linear-gradient(135deg, #3b82f6, #1e40af);
    transform: scale(1.2);
}

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

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        padding: 10px;
        height: calc(100vh - 20px);
    }
    
    .users-sidebar {
        width: 200px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .emoji-panel {
        width: 250px;
        right: 10px;
    }
}

@media (max-width: 480px) {
    .users-sidebar {
        display: none;
    }
    
    .message {
        max-width: 95%;
    }
    
    .chat-header {
        padding: 1rem;
    }
    
    .chat-header h1 {
        font-size: 1.3rem;
    }
}